Linux OOM Killer — Out of Memory Process Killed
Criticalerrno
Overview
Linux OOM (Out of Memory) Killer automatically terminates processes when the system runs critically low on memory to prevent a complete system hang.
Key Details
- OOM Killer is a kernel mechanism that kills processes to free memory
- Triggered when physical RAM and swap are exhausted
- Selects the process consuming the most memory with the least importance
- Logged in dmesg and /var/log/kern.log with 'Out of memory' message
- Can kill critical services causing cascading failures
Common Causes
- Application memory leak consuming all available RAM
- Insufficient RAM for the workload
- No swap space configured or swap is full
- Memory overcommit allowing more allocation than available
- Multiple memory-intensive processes running simultaneously
Steps
- 1Check OOM events: dmesg | grep -i 'out of memory\|oom'
- 2Identify the killed process: dmesg | grep 'Killed process'
- 3Add swap space: fallocate -l 4G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile
- 4Adjust overcommit: echo 2 > /proc/sys/vm/overcommit_memory (strict mode)
- 5Protect critical processes: echo -1000 > /proc/PID/oom_score_adj
Tags
linuxoomout-of-memorykernelprocess
More in Errno
linux-errno-1-epermLinux errno 1 (EPERM) — Operation Not Permitted
Warninglinux-errno-2-enoentLinux errno 2 (ENOENT) — No Such File or Directory
Warninglinux-errno-5-eioLinux errno 5 (EIO) — Input/Output Error
Errorlinux-errno-11-eagainLinux errno 11 (EAGAIN) — Resource Temporarily Unavailable
Informationallinux-errno-12-enomemLinux errno 12 (ENOMEM) — Out of Memory
Criticallinux-errno-13-eaccesLinux errno 13 (EACCES) — Permission Denied
WarningFrequently Asked Questions
It uses an oom_score based on memory usage, process age, and priority. Highest score gets killed. Root processes get a slight bonus.