Error Codes Wiki

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

  1. 1Check OOM events: dmesg | grep -i 'out of memory\|oom'
  2. 2Identify the killed process: dmesg | grep 'Killed process'
  3. 3Add swap space: fallocate -l 4G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile
  4. 4Adjust overcommit: echo 2 > /proc/sys/vm/overcommit_memory (strict mode)
  5. 5Protect critical processes: echo -1000 > /proc/PID/oom_score_adj

Tags

linuxoomout-of-memorykernelprocess

More in Errno

Frequently 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.