1

OOM Killer Doesn’t Work Properly [SOLVED]

 1 year ago
source link: https://www.shellhacks.com/oom-killer-doesnt-work-properly-solved/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

OOM Killer Doesn’t Work Properly [SOLVED]

An out-of-memory (OOM) killer is a mechanism of the Linux kernel that is supposed to terminate (kill) high memory consuming processes if a system is critically low on memory.

Unfortunately, the OOM killer doesn’t always work properly.

It often starts too late, when the system is already out of memory, so it doesn’t have enough memory for itself, that leads to the frozen system.

This note shows how to call the OOM killer earlier, before the system gets into an unresponsive state.

Fix Not Working OOM Killer

If the OOM killer doesn’t save your system from getting out of memory, as an alternative, you can try to use an earlyoom daemon.

When both your available memory and free swap drop below 10% of the total memory available, the earlyoom will kill the largest process.

Run the commands below, depending on your OS, to install the earlyoom and configure it to start on boot:

# Debian 10+ and Ubuntu 18.04+
$ sudo apt update
$ sudo apt install earlyoom

# Fedora and RHEL 8 with EPEL
$ sudo dnf install earlyoom
$ sudo systemctl enable --now earlyoom

# Arch Linux
$ sudo pacman -S earlyoom
$ sudo systemctl enable --now earlyoom

To check the earlyoom logs, execute:

$ journalctl -u earlyoom

In order to see the earlyoom in action, create/simulate a memory leak and let the earlyoom do what it does:

$ tail /dev/zero
- your system will start hanging and then, voila -
Terminated

Once the earlyoom is installed and enabled, you should have no issues with not working OOM killer anymore.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK