Thursday, December 2, 2010

Steps to disable OOM Killer on Linux

OOM kills any process which has been waiting for a long time. But some times, we need to avoid this and make sure these long waiting processes are allowed to complete even if it takes much more time.
To disable OOM, follow the below steps.

Check status of oom-killer:

# cat /proc/sys/vm/oom-kill

Turn oom-killer off/on:
# echo "0" > /proc/sys/vm/oom-kill
# echo "1" > /proc/sys/vm/oom-kill

To make this change take effect at boot time, add the following
to /etc/sysctl.conf:
vm.oom-kill = 0

For processes that would have been killed, but weren't because the oom-
killer is disabled, you'll see the following message
in /var/log/messages:
"Would have oom-killed but /proc/sys/vm/oom-kill is disabled"

4 comments:

  1. /proc/sys/vm/oom-kill does not exist.

    ReplyDelete
  2. Hi,

    when I try the command
    echo "0" > /proc/sys/vm/oom-kill

    i get this error:

    cannot create /proc/sys/vm/oom-kill: Directory nonesistent

    Is there another directory when I could find the oom-killer?

    Thank you.

    ReplyDelete
  3. This is for RHEL. Can you please let me know your OS details.

    You can always add the following to disable oom-killer at startup.
    File:- /etc/sysctl.conf
    vm.oom-kill = 0

    ReplyDelete
  4. On OpenSUSE, the file is /proc/sys/vm/oom_kill_allocating_task to view the status and just 'oom_kill_allocating_task' for the sysctl key, which would be set to '0'. Hope this helps (I know it's 3 years later!)

    ReplyDelete