A service gets killed with `Memory cgroup out of memory: Killed process ...` but the host has 20 GB free.
IntermediateTroubleshootingProcesses, memory and OOM
Answer
Likely causes → The service's cgroup limit (MemoryMax= in systemd or a container limit) was reached, not host memory.
Diagnose →
systemctl show app -p MemoryMax -p MemoryCurrent -p MemoryPeak
cat /sys/fs/cgroup/system.slice/app.service/memory.events # oom_kill count
Fix → Raise the limit if the usage is legitimate, or fix the leak. Use MemoryHigh= slightly below MemoryMax= to throttle before killing.
Prevent → Track memory.current against the limit per service.
More on 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:...`.Beginner`ps` shows dozens of processes in state `Z` with `<defunct>`.BeginnerZombie count keeps climbing into the thousands and new processes fail with `fork: Resource temporarily unavailable`.AdvancedAn app crashes under load with `java.io.IOException: Too many open files` (or `EMFILE`).BeginnerYou raised `nofile` in `/etc/security/limits.conf` to 65536, but the service still shows `Max open files 1024`.IntermediateThe whole host can't open files: `VFS: file-max limit 98304 reached` in `dmesg`.Advanced