What the message looks like
Out of memory: Killed process 2314 (php-fpm8.3) total-vm:812344kB, anon-rss:402112kB, file-rss:0kB, shmem-rss:20480kB, UID:33 pgtables:1240kB oom_score_adj:0Common causes
- Too many PHP-FPM workers or database buffers for the available RAM.
- A memory leak in an application that grows over hours.
- No or too little swap, so load spikes are not absorbed.
- cgroup limit (
MemoryMax, Docker--memory) reached – then “Memory cgroup out of memory”. - One-off jobs like backups, imports or image processing need a lot of memory briefly.
Check
- Find OOM events in the kernel log
journalctl -k --since '24 hours ago' | grep -iE 'out of memory|oom-kill|Killed process' - Show free memory and swap
free -h; swapon --show - Show processes using the most memory
ps -eo pid,user,rss,comm --sort=-rss | head -n 10 - Show the memory limits of the affected service
systemctl show php8.3-fpm.service -p MemoryMax -p MemoryCurrent -p OOMPolicy
Fix
- Match
pm.max_childrento RAM: available memory divided by average worker size. - Limit database buffers, e.g.
innodb_buffer_pool_sizeto fit the rest of the system. - Add some swap so short spikes do not cause an immediate kill.
- Protect critical services with
OOMScoreAdjust=-500in the unit, cap non-critical ones withMemoryMax. - Monitor memory usage over time to spot leaks early.
FAQ
Why was the database killed although PHP used the memory?
The OOM killer picks by size and oom_score_adj, not by who caused it. Large services like MariaDB are therefore often hit first.
Does disabling overcommit help?
Rarely. With vm.overcommit_memory=2 applications fail when allocating instead. Better set per-service limits and match usage to RAM.