Linux system errors

Linux 12 Out of Memory (ENOMEM)

12
HighLinux System

Out of Memory (ENOMEM) — the kernel cannot allocate the requested amount of memory

What 12 Means

The 12 error on the Linux system errors indicates out of memory (enomem) — the kernel cannot allocate the requested amount of memory. This typically occurs due to system physical ram and swap space are both exhausted.

ENOMEM (errno 12) is returned by malloc, mmap, and other memory allocation calls when the kernel cannot satisfy the request. The Linux OOM Killer may terminate processes to recover memory before this error is returned.

Technical Background

Linux manages physical and virtual memory through the kernel's memory allocator. When both RAM and swap are exhausted, the allocator returns ENOMEM to the calling process or invokes the OOM Killer to free memory by terminating a process.

Real-time memory usage is visible through 'free -h', 'vmstat', and '/proc/meminfo'. Swap space provides a secondary memory pool when physical RAM is exhausted, reducing the frequency of OOM conditions at the cost of increased latency.

Common Causes

  • System physical RAM and swap space are both exhausted
  • Process requesting a memory allocation larger than available virtual memory
  • Memory leak in a long-running process gradually consuming all available RAM

Typical Scenarios

  • Java application with an undersized heap growing until the system runs out of RAM
  • Compilation of large C++ projects exhausting available memory on low-RAM systems
  • Container running without memory limits consuming all host memory

What to Know

ENOMEM is a resource exhaustion condition where both physical RAM and swap are fully committed. The Linux OOM Killer may terminate processes to recover memory before ENOMEM is returned to the calling process — meaning the error appears only when OOM killing cannot or does not free enough memory.

Frequently Asked Questions

Common questions about Linux 12 error

The OOM Killer is a kernel mechanism that terminates one or more processes when the system runs completely out of memory. It selects victims based on memory usage and process priority to free enough memory to keep the system running.

Related Error Codes