The OOM killer keeps killing `sshd` and the database instead of the leaking batch job.
AdvancedTroubleshootingProcesses, memory and OOM
Answer
Likely causes → OOM victim selection is based on oom_score (memory use plus oom_score_adj); priorities aren't set.
Diagnose →
for p in $(pgrep -d' ' 'sshd|postgres|batch'); do echo "$p $(cat /proc/$p/oom_score) $(cat /proc/$p/comm)"; done
Fix → Protect critical services in their units: OOMScoreAdjust=-900 for the DB and sshd (-1000 disables killing). Make the batch job preferred: OOMScoreAdjust=500 and cap it with MemoryMax=.
Prevent → Every service gets a memory limit and an OOM priority in its unit.
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:...`.BeginnerA service gets killed with `Memory cgroup out of memory: Killed process ...` but the host has 20 GB free.Intermediate`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`.Intermediate