#include #include #include #include int main( int argc, char *argv[]) { int bytes = 10000000; // 10MB int memory = 1000000000; // artificial ceiling of 1GB if (argc > 1) memory = atoi(argv[1]); if (argc > 2) bytes = atoi(argv[2]); FILE *file; file = fopen("/dev/urandom","r"); printf("reading %d bytes\n",bytes); char *food; food = malloc(bytes * sizeof(char)); int size = fread(food,1,bytes,file); printf("read %d from /dev/urandom\n",size); char *chomper; printf("Eating %d bytes of precious memory\n",memory); chomper = malloc(memory); int c; int offset = 0; // sleep(10); // while(sizeof(chomper) < memory) { while(offset < memory) { memcpy(&chomper[offset],food,size); offset += size; printf("chomped at %d\n",offset); // usleep(200000); } char *rnd; rnd = malloc(bytes * sizeof(char) * 5); char str[5]; // scanf("%s",str); fread(rnd,1,bytes * 5,file); }