/* This program tries to allocate a tebibyte of memory and writes a byte to each page. If this does not work, try executing the following command before on Linux: sh -c 'echo 1 >/proc/sys/vm/overcommit_memory' */ #include #include #include int main() { char *x = malloc(1024L*1024L*1024L*1024L); size_t i = 0; if (x == NULL) { fprintf(stderr,"Cannot allocate that much memory!\n"); return EXIT_FAILURE; } for(;;i+=4096) { x[i] = 0; if (i%(256*1024*1024)==0) sleep(1); } return EXIT_SUCCESS; }