Error Codes Wiki

Linux OOM Killer — Out of Memory Process Killed

Criticalerrno

About Linux OOM Killer

Linux OOM (Out of Memory) Killer automatically terminates processes when the system runs critically low on memory to prevent a complete system hang. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: 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. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: 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. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Check OOM events: dmesg | grep -i 'out of memory\|oom'. Identify the killed process: dmesg | grep 'Killed process'. Add swap space: fallocate -l 4G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile. Adjust overcommit: echo 2 > /proc/sys/vm/overcommit_memory (strict mode). Protect critical processes: echo -1000 > /proc/PID/oom_score_adj. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

How does the OOM Killer choose which process to kill?

It uses an oom_score based on memory usage, process age, and priority. Highest score gets killed. Root processes get a slight bonus.

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.