Interview Prep/Linux/Processes, memory and OOM

A Java service disappears without an error in its own log. `dmesg` shows `Out of memory: Killed process 4121 (java) total-vm:... anon-rss:...`.

BeginnerTroubleshootingProcesses, memory and OOM
Answer

Likely causes → The kernel OOM killer picked the biggest process when the host (or its cgroup) ran out of memory.

Diagnose →

dmesg -T | grep -Ei 'out of memory|oom-kill|killed process'
journalctl -k -b | grep -i oom
free -h; ps aux --sort=-rss | head

Fix → Find out who used the memory (the OOM report lists every process's RSS). Size the JVM heap to fit (-Xmx well below RAM, leaving room for metaspace, threads and the OS), add RAM, or move other workloads off.

Prevent → Alert on memory available and on oom_kill counters (/proc/vmstat), and set per-service memory limits.

All Linux questions Roadmap: Linux

More on Processes, memory and OOM