The Out-of-Memory (OOM) Killer is a Linux kernel mechanism that automatically selects and terminates one or more processes when the system is critically low on available memory, aiming to free resources and keep the core operating system functional. It activates as a last resort when all other memory reclamation efforts, such as flushing disk caches and swapping, have failed to prevent an imminent kernel panic. The selection algorithm typically targets the process consuming the most memory with the lowest priority, calculated via an adjustable oom_score.
Glossary
Out-of-Memory (OOM) Killer

What is the Out-of-Memory (OOM) Killer?
A critical Linux kernel process that terminates applications to prevent total system failure during severe memory exhaustion.
In GPU-accelerated machine learning environments, the OOM Killer is a critical failsafe that can terminate a model inference or training job if it exhausts both GPU and system memory, especially when using unified memory or memory oversubscription. Systems engineers mitigate its disruptive action by configuring memory cgroups to impose hard limits, adjusting process oom_score_adj values, and ensuring adequate swap space. Its intervention, while preserving system stability, causes immediate job failure, making proactive memory monitoring essential for production ML workloads.
Key Characteristics of the OOM Killer
The Out-of-Memory Killer is a last-resort process in the Linux kernel designed to prevent a complete system crash by terminating one or more processes when available memory is critically exhausted.
Triggering Condition
The OOM Killer activates when the system faces a critical memory shortage and cannot satisfy an allocation request, even after the kernel has exhausted all other memory management techniques. This includes:
- Aggressive swapping to disk (if swap is enabled and not full).
- Dropping clean page caches and reclaimable slab objects.
- Compacting memory.
When these measures fail, the kernel invokes the OOM Killer to free memory by force, preventing a kernel panic.
Selection Algorithm (oom_score)
The kernel selects a victim process using a heuristic badness score (oom_score). This score, visible in /proc/[pid]/oom_score, is calculated based on multiple factors to identify the 'best' process to kill:
- Memory Usage: The primary factor. Processes using more memory, especially resident set size (RSS), receive higher scores.
- Process Lifetime: Long-running daemons and critical system processes are penalized with lower scores.
- User Privileges: Root-owned processes typically have their score adjusted to be less likely targets.
- CPU Time: Processes that have consumed significant CPU time may be penalized.
- OOM Score Adjustment (
oom_score_adj): A user-settable value from -1000 to +1000 that directly shifts the final score, allowing administrators to protect critical processes or mark others as preferred victims.
Impact on ML/GPU Workloads
In machine learning inference servers, the OOM Killer poses a significant risk, often terminating the very process managing the GPU. Key failure scenarios include:
- Host Memory Exhaustion: A large language model inference engine, like vLLM or TensorRT-LLM, may allocate substantial host memory for request queues, tokenizers, and communication buffers. If this exhausts system RAM, the kernel may kill the inference server process.
- Indirect GPU Memory Pressure: While the OOM Killer doesn't directly manage GPU memory, system memory is used for GPU driver control structures, pinned memory for DMA, and Unified Memory pages. Exhausting system memory can cripple GPU operations.
- Cascading Failures: Killing a critical orchestration process (e.g., a Kubernetes pod manager) can lead to uncontrolled restarts and service disruption.
Configuration and Mitigation
System administrators and ML Ops engineers can configure the OOM Killer's behavior to protect critical services:
oom_score_adj: Set this to -1000 for essential processes (e.g., the inference server, monitoring agent) in a container'sspec.containers[].resources.limits.oomScoreAdjor viaecho -1000 > /proc/[pid]/oom_score_adj.- Memory Cgroups (Control Groups): The primary modern defense. By placing workloads in cgroups with strict memory limits (
memory.limit_in_bytes), you ensure a single container's memory exhaustion triggers a cgroup-specific OOM kill, isolating the failure and protecting the host system. - Disabling the OOM Killer: Setting
vm.overcommit_memory = 2and providing ample swap can make the kernel refuse allocations rather than invoke the killer, but this often causes application-level failures instead. - Monitoring: Tools like
dmesgand the system log (/var/log/syslog) capture OOM Killer events, showing the killed process's PID and itsoom_score.
Relation to GPU Memory Management
The Linux host OOM Killer is distinct from, but interacts with, GPU-level memory management:
- Separate Domains: The OOM Killer operates on system (host) RAM. GPU device memory (VRAM) is managed by the GPU driver and runtime (e.g., CUDA). A GPU-side out-of-memory error (
cudaErrorMemoryAllocation) is a different event handled within the application. - Unified Memory Pressure: When using Unified Virtual Memory (UVM), pages can migrate between host and GPU memory. Severe host memory pressure can stall these migrations, indirectly affecting GPU performance and potentially leading to host OOM conditions.
- Pinned Memory Overhead: Allocating large amounts of page-locked (pinned) host memory for fast GPU transfers reduces the pool of swappable memory for the OS, increasing the risk of triggering the OOM Killer for other processes.
Best Practices for Inference Serving
To prevent the OOM Killer from disrupting production model serving:
- Set Explicit Limits: Always use memory cgroups (via Kubernetes
resources.limits.memoryor Docker-m) to enforce hard boundaries on container memory usage. - Monitor Memory Trends: Use profiling tools to understand the resident set size (RSS) of your inference server, not just its GPU memory allocation.
- Size Host Memory Appropriately: Ensure the physical host has sufficient RAM for the OS, monitoring tools, and the inference engine's host-side overhead (often 20-30% beyond model weights).
- Tune Swappiness: Adjust
vm.swappinessto a lower value (e.g., 10) to make the kernel prefer caching over swapping, but be aware this can make the OOM Killer activate sooner. - Implement Graceful Degradation: Design your inference service to handle memory pressure signals (e.g., listening for
SIGKILLor monitoring cgroup pressure) and shed load or queue requests before a forced termination occurs.
How the OOM Killer Works: The Selection Algorithm
The Out-of-Memory Killer's core function is to select a victim process for termination. It does not act randomly but uses a deterministic scoring algorithm to minimize system disruption.
The kernel calculates an OOM score for each eligible process, stored in /proc/[pid]/oom_score. This score is derived from the process's oom_score_adj value (a user-configurable adjustment from -1000 to 1000) and an internal heuristic. The heuristic heavily weights the process's resident memory usage and CPU time, favoring long-running, memory-intensive processes. Child processes typically inherit and contribute to the parent's memory footprint in this calculation.
The process with the highest OOM score is selected for termination. The kernel sends it a SIGKILL signal, which the process cannot catch or ignore. After termination, all the process's memory is reclaimed by the kernel. The algorithm may run multiple times if the initial kill does not free sufficient memory. In containerized environments like Docker, the OOM Killer operates within the memory cgroup of the offending container, targeting processes inside it first.
OOM Killer vs. Proactive Memory Management
A comparison of the reactive Linux kernel OOM Killer mechanism against proactive software techniques for managing GPU memory pressure in machine learning inference workloads.
| Feature / Metric | OOM Killer (Reactive) | Proactive Memory Management (Preventative) | Ideal Hybrid Approach |
|---|---|---|---|
Core Mechanism | Terminates processes post-OOM | Pre-allocates pools, monitors usage, swaps/caches data | Combines monitoring with graceful degradation & fallback |
Trigger Condition | System-wide memory exhaustion | Predefined high-watermark (e.g., >85% GPU memory used) | Configurable thresholds with multiple escalation levels |
Impact on ML Inference | Process kill causes request failure, lost context, job restart | Controlled performance degradation (increased latency) | Minimal latency impact until severe pressure, then managed fallback |
Determinism & Predictability | Non-deterministic; uses | Highly deterministic based on configurable policies | Policy-driven with predictable failure modes |
Data Loss Risk | High (in-flight requests and model state lost) | Low (state preserved via caching/checkpointing) | Very Low (state checkpointed before pressure triggers) |
Typical Latency Added | N/A (catastrophic failure) | 5-15% (for swapping/cache management) | <5% (optimized pooling & prefetching) |
Implementation Complexity | Kernel-default; no app code required | High (requires integration into app/model server) | Moderate-High (requires policy engine & integration) |
Best For | General-purpose systems, last-ditch safety net | Mission-critical, high-availability ML inference services | Production ML serving where cost control & reliability are paramount |
Frequently Asked Questions
The Out-of-Memory (OOM) Killer is a critical Linux kernel process that terminates applications to prevent system-wide crashes during severe memory exhaustion. These questions address its operation, impact on AI workloads, and mitigation strategies for production systems.
The Out-of-Memory (OOM) Killer is a process within the Linux kernel that automatically selects and terminates one or more running processes when the system is critically low on available memory, aiming to free resources and keep the kernel operational.
Its operation follows a deterministic algorithm:
- The kernel continuously monitors memory pressure. When available memory and swap space fall below a critical threshold, the OOM killer is invoked.
- It evaluates all running processes and assigns each an OOM score (
oom_scorevisible in/proc/[pid]/). This score is calculated based on the process's memory consumption, runtime, process niceness (nicevalue), and whether it runs as a privileged user (root). - The process with the highest OOM score is selected for termination. The kernel sends it a
SIGKILLsignal (signal 9), which immediately terminates the process without allowing it to clean up. - The memory held by the terminated process is reclaimed by the kernel. If memory pressure remains critically high, the OOM killer repeats the process.
The primary goal is to prevent a complete system lockup or kernel panic by sacrificing specific processes to preserve overall system stability.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The OOM Killer is one component in a broader ecosystem of memory management. These related concepts define the mechanisms, policies, and hardware interactions that govern how memory is allocated, accessed, and reclaimed in high-performance computing environments.
Memory Cgroup (Control Group)
A Linux kernel feature that limits, accounts for, and isolates the memory resource usage of a collection of processes. It is the primary mechanism for enforcing memory quotas on containers (e.g., Docker, Kubernetes). The OOM Killer uses cgroup-level memory pressure and over-limit status as critical signals when selecting a victim process to terminate.
- Enforces Hard Limits: Prevents a single container from consuming all host memory.
- Hierarchical Accounting: Memory usage is tracked up a tree of cgroups, allowing for subtree limits.
- Direct Link to OOM: When a cgroup exceeds its limit and cannot reclaim memory, an OOM kill is triggered within that cgroup's scope.
Page-Locked Memory (Pinned Memory)
Host (CPU) memory that is prevented from being paged out to disk by the operating system. This is a prerequisite for high-bandwidth Direct Memory Access (DMA) transfers to GPU device memory. Excessive allocation of pinned memory can itself trigger system-wide memory pressure, indirectly leading to OOM Killer activation.
- DMA Requirement: Enables GPUs to directly read/write host memory without CPU intervention.
- Non-Swappable: Cannot be paged to disk, reducing available memory for other processes.
- Performance vs. Risk: Critical for throughput but must be managed carefully to avoid inducing OOM conditions.
Memory Overcommit (Oversubscription)
A technique where the total memory allocated by processes exceeds the available physical RAM. The kernel allows this, relying on the assumption that not all allocated memory will be used simultaneously. This is common in GPU workloads using Unified Virtual Memory (UVM). When overcommitted memory is actually accessed (demand paging), it can lead to severe swapping and memory pressure, forcing the OOM Killer to intervene.
- Virtual Memory Foundation: Relies on paging (swap) to back excess allocations.
- High-Risk for GPUs: GPU page faults to system swap are extremely slow, causing system-wide stalls.
- OOM Trigger: Aggressive overcommit is a direct precursor to OOM events.
Demand Paging
A virtual memory technique where data is transferred from a slower backing store (like system RAM or SSD) into faster GPU memory only when the GPU attempts to access it, signaled by a page fault. In GPU contexts with Unified Virtual Memory, excessive demand paging can create I/O bottlenecks and memory pressure on the host system, contributing to the conditions that activate the OOM Killer.
- On-Access Loading: Memory is loaded lazily, not pre-emptively.
- Page Fault Cost: GPU page faults to host memory or disk are high-latency events.
- Cascading Pressure: Slow paging can cause process stalls, leading to backlog and increased memory residency.
OOM Score & Badness Heuristic
The internal algorithm the Linux OOM Killer uses to select a victim process. It calculates an 'oom_score' for each process based on a 'badness' heuristic. The process with the highest score is killed. Understanding this heuristic is key to influencing the Killer's decisions.
Heuristic Factors Include:
- Memory Usage: Proportional and absolute memory consumption.
- Process Lifetime: Long-running processes may be penalized.
- Process Priority (nice value): Lower priority (higher nice) processes score higher.
- OOM Score Adjustment: Administrators can adjust
/proc/[pid]/oom_score_adjto protect or expose specific processes.
Memory Cgroup OOM Killer
A specialized instance of the OOM Killer that operates within the scope of a memory cgroup. When a cgroup hits its hard memory limit and cannot reclaim enough memory, this killer terminates a process within that cgroup instead of a system-wide process. This provides crucial isolation, preventing a rogue container from taking down the entire host.
- Container-Safe: Failure is contained to the offending container/pod.
- Kubernetes Integration: This is the mechanism behind Pod eviction on memory pressure in Kubernetes.
- Policy-Driven: Often integrated with higher-level orchestration policies (e.g., Quality of Service classes for Pods).

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us