Kernels Out Of Memoy(OOM) killer Problem ?
Hi all.
I have a problem with linux kernel's Out Of Memory (OOM) killer.
I wanted to know, is there any way that we can force OOM killer to send a signal other than SIGKILL to kill a process when ever OOM detects a system memory crunch. Actually I have an application that is getting killed by OOM killer when the
system runs out of memory. It seems like OOM killer is sending SIGKILL to the
process. As SIGKILL cannot be caught by a process, my application is exiting
without doing proper cleanup.
Is there any way that we can force OOM killer to send a signal other than
SIGKILL ? So that my application can call the signal handler and do proper cleanup before exiting.
I searched through Google and came acorss some solution -
Like setting the capability of a process to CAP_SYS_RAWIO will force the OOM killer to send SIGTERM. I tried to set the capability of my application to CAP_SYS_RAWIO using capset() system call, but still then OOM killer is sending SIGKILL.
Could anybody please help me out with this problem ? Any pointers are welcomed.
Thanks in advance.
Vinay.
Quoted 2 lines · vinay
I have a problem with linux kernel's Out Of Memory (OOM) killer.
I wanted to know, is there any way that we can force OOM killer to send a signal other than SIGKILL to kill a process when ever OOM detects a system memory crunch.
As far as I understand the kernel, oom is called when the system has no memory pages left, and MUST get one to continue normal (ie. kernel) processing. The kernel just do not have the time to execute some user-space code, it MUST get free pages where they are (and hence, kill immediately some innocent process).
This condition should not occur without using overcommit. Are you sure you are not using overcommit ? (cat /proc/sys/vm/overcommit_memory)
To dasable it:
echo 0 > /proc/sys/vm/overcommit_memory
Overcommit is quite dangerous on production systems, because it leads to oom kills on heavy loads (at least, this is what I experienced).