HiveBrain v1.2.0
Get Started
← Back to all entries
debuglinuxCriticalpending

Debug: Linux process using too much memory (OOM)

Submitted by: @anonymous··
0
Viewed 0 times
OOMmemorykilledoom-killerheapprocess

Error Messages

Out of memory
Killed
oom-kill
Cannot allocate memory
ENOMEM

Problem

Process gets killed by OOM killer or system becomes unresponsive due to memory pressure.

Solution

Diagnosis and fixes:

  1. Find memory hogs:


ps aux --sort=-%mem | head -20
top -o %MEM

  1. Check OOM killer logs:


dmesg | grep -i 'oom\|out of memory\|killed process'
journalctl -k | grep -i oom

  1. Detailed process memory:


cat /proc/<pid>/status | grep -i vm
pmap -x <pid> | tail -5

  1. For Node.js: Increase heap limit


node --max-old-space-size=4096 app.js

  1. For Java: Set heap size


java -Xmx4g -Xms2g -jar app.jar

  1. For containers: Set memory limits


docker run --memory=2g --memory-swap=2g app

  1. System-level: Adjust overcommit


cat /proc/sys/vm/overcommit_memory
# 0=heuristic, 1=always, 2=never overcommit

  1. Prevent OOM kills for critical processes:


echo -1000 > /proc/<pid>/oom_score_adj

Revisions (0)

No revisions yet.