c - malloc behaves differently on different machines -
I see completely different behaviors while running a part of the program that tries to cross the RSS on different machines. The code is something like this:
... char ** s = (char **) malloc (10000 * size (four *)); For (i = 0; i & lt; 10000; i ++) {s [i] = (four *) molk (1000 * 1000 * size (four)); If (S [i] == NULL) {printf ("s [% d] can not allocate memory"), i); Exit (1); }} Int j = 0; While (1) {for (i = 0; i & lt; 10000; i ++) {for (j = 0; j & lt; 1000 * 1000; j ++) {s [i] [j] = 1 ; } If ((i% 100) == 0) printf ("i =% d \ n", i); }} For (i = 0; i & lt; 10000; i ++) free (s [i]); Free (s); ...
The above code attempts to allocate approximately 10GB of memory using malloc. The first two machines tried to run this code on Linux kernel 2.6 and the previous one ran the Linux kernel 2.4. Here are the behaviors I see on these machines:
Machine1: Memory is allocated using the memory of redundancy, but when assigning a value to memory locations in the loop, it is only the RSS Only allows Thus OOM kills killer process when I print = 3800 which is approximately 4 GB of this machine memory. Machine 2: Memory is allocated using memory overcommit and while loop allocates pages with virtual memory. Machine 3: This machine has only 2 GB of memory, after I = 3800 is printed, the process becomes slightly slower. Memory can not be allocated It seems that the overhead set is not set or does not support allocating virtual machine pages using kernel 2.4 malloc! Thus for the loop when it is allocated memory for i = 2138, it goes out first
The action I want is happening in Machine 2. Does anyone know that to allow the OS to use malloc to allocate virtual memory pages to determine which option (kernel?) Is the option and when the memory required is higher than the RSS?
Thanks
You will not be able to assign 100 GB to 32-bit machines And you can find it using regular pointers, which seems to use your code. The fact is that the machine 1 ends the process when it hits about 4 GB and machine 2 hits, it does not strongly suggest that machine 2 is running a 64-bit OS.
Comments
Post a Comment