Hi,
My program was running for a whole night. after 12 hours i got an error message "Cannot allocate memory" during the shmat commmand. So can you please let me know what could be the reason? is there any solution?
thanks in advance.
Regards,
Mano
Hi,
My program was running for a whole night. after 12 hours i got an error message "Cannot allocate memory" during the shmat commmand. So can you please let me know what could be the reason? is there any solution?
thanks in advance.
Regards,
Mano
You have a memory leak or need more swap space.
but i had enough shared memory in the server... i mean if i do the cat /proc/sys/kernel/shmall the response is 1152921504606846720.
cat /proc/sys/kernel/shmmax
18446744073709551615
SHMMAX may be set to allow 4398046511103 gigabytes of shared memory, you don't actually have 4398046511103 gigabytes of memory available. Go over the amount of memory and swap you have installed and you'll hit limits, not necessarily when you allocate it but later, when you try to use it... That's the sort of thing a slow memory leak could do overnight.
That number's related to the 64-bit maximum integer. Having SHMMAX set to that means 'no limit'.
actually once i observed the problem from then on my program was not working due to same reason.
BTW, one more question is from the shmmax value i can see that its around some giga bytes. but that much memory is not available in the system. so it means will shmmax size will be set to 32MB(default shared memory maximum size)?
Once i got this issue, then on the same issue is continuously occuring till i restart the system.
---------- Post updated at 10:41 AM ---------- Previous update was at 10:39 AM ----------
ipcs command output:
ipcs -m
0x00000000 904855586 user 777 131072 2 dest
0x0052e2c1 1401815075 user 600 37879808 5
0x0000f24f 1401847844 root 644 28 22
0x00238003 1401880613 root 644 16 2
0x00000000 1402142758 user 777 12096 2 dest
0x00000000 1291714599 user 777 15840 2 dest
Memory leaks and swap space are about VM limits. A 32 bit program cannot allocate more than 2-4 GBytes of space, if it does not run out of swap first. Of course, this has nothing to do with "shared memory", it has to do with overhead malloc() calls to support that "shared memory".
You just decide either there is a need for that much VM in your app and you need 64 bit code or bigger swap space, or if it signifies a failure to free() or delete.
(BTW, "shared memory" is, in my opinion, too root-dependent, system setup dependent, and since mmap() and mmap64(), very obsolete!)