The OOM killer (Out Of Memory killer) is a Linux kernel mechanism that kicks in when the system is critically short of memory. Rather than allowing the kernel itself to run out of memory and panic, the OOM killer selects a victim process and terminates it, freeing its memory so the system can continue running.
The victim is chosen by score, based on /proc/<pid>/oom_score — a combination of memory use, runtime, nice value, and administrator adjustments via /proc/<pid>/oom_score_adj. The bigger the process and the lower its priority, the more likely it is to be killed. Services that must not be killed can be protected by setting oom_score_adj to a large negative value, or systemd's OOMScoreAdjust=.
When a process is OOM-killed, the kernel logs a verbose message to dmesg:
[123456.789] Out of memory: Killed process 4321 (python) total-vm:2048000kB
[123456.789] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null)...
Watching for these messages with journalctl -k | grep -i oom or dmesg | grep -i kill is an essential troubleshooting step when services disappear without obvious cause. Systemd's systemd-oomd and per-cgroup OOM scoring (memory.oom.group) give finer-grained control on modern systems, allowing OOM decisions to be made per service rather than globally.
Discussed in:
- Chapter 10: Processes and Job Control — The OOM Killer
Also defined in: Textbook of Linux