Linux system errors
Linux 12 Out of Memory (ENOMEM)
Reviewed for reference consistency: April 11, 2026
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.
How to fix 12
General informational guidance, not professional advice. Commands can affect your system or data — back up first and proceed at your own risk. FixerCode is an independent reference, not affiliated with any vendor mentioned.
Check current memory and swap
Confirm whether physical RAM and swap are actually exhausted at the moment the allocation fails.
free -hFind the processes using the most memory
Sort processes by resident memory to identify the consumer that is driving the system toward exhaustion.
ps aux --sort=-%mem | headCheck for a container or cgroup limit
Inside containers, ENOMEM often comes from a cgroup limit far below total host memory rather than real exhaustion.
cat /sys/fs/cgroup/memory.maxAdd headroom or raise the limit
Give the workload more room by adding swap on the host or increasing the container memory limit, then retry.
docker run --memory=2g your-image
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.