Finding which process was killed by Linux OOM killer

LinuxLinux Kernel

Linux Problem Overview


When Linux runs out of memory (OOM), the OOM killer chooses a process to kill based on some heuristics (it's an interesting read: <http://lwn.net/Articles/317814/>;).

How can one programmatically determine which processes have recently been killed by the OOM killer?

Linux Solutions


Solution 1 - Linux

Try this out:

grep -i 'killed process' /var/log/messages

Solution 2 - Linux

Try this so you don't need to worry about where your logs are:

dmesg -T | egrep -i 'killed process'

-T, --ctime - Print human-readable timestamps.

Solution 3 - Linux

Now dstat provides the feature to find out in your running system which process is candidate for getting killed by oom mechanism

dstat --top-oom
 --out-of-memory---
  kill score
 java           77
 java           77
 java           77

and as per man page

  --top-oom
          show process that will be killed by OOM the first

Solution 4 - Linux

Try this out:

grep "Killed process" /var/log/syslog

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYangView Question on Stackoverflow
Solution 1 - LinuxJohn FeminellaView Answer on Stackoverflow
Solution 2 - LinuxJose FernandezView Answer on Stackoverflow
Solution 3 - LinuxPrashant LakheraView Answer on Stackoverflow
Solution 4 - LinuxPraveenView Answer on Stackoverflow