C Program on Linux to exhaust memory -
I want to write a program to consume all the memory available to understand the result. I have heard that Linux starts kicking the processes once it is unable to allocate memory.
Can anyone help me with such a program?
I wrote the following, but memory does not end:
#include & lt; Stdlib.h & gt; Int main () {while (1) {Molk (1024 * 1024); } Return 0; }
You must write the allocated blocks. If you just ask for memory, then Linux may leave a reservation for memory, but until the memory is accessed, nothing will be allocated.
int main () {while (1) {void * m = molok (1024 * 1024); Memset (m, 01024 * 1024); } Return 0; }
You only need to write 1 byte (normally 4096 bytes on x86) on every page.
Comments
Post a Comment