Docs / Troubleshooting / Debugging Memory Issues and OOM Kills

Debugging Memory Issues and OOM Kills

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 29 views · 1 min read

Detecting OOM Kills

# Check kernel log for OOM events
dmesg | grep -i "out of memory"
dmesg | grep -i "oom"

# Check system journal
journalctl -k | grep -i oom

Understanding Memory Usage

# Overview
free -h

# Per-process memory usage
ps aux --sort=-%mem | head -15

# Detailed view
cat /proc/meminfo

Key distinction: Linux uses free memory for disk caching. This is normal and healthy. Look at the "available" column in free -h, not "free".

Finding Memory Leaks

# Monitor a specific process over time
watch -n 5 "ps -o pid,vsz,rss,comm -p $(pgrep php-fpm | head -1)"

# VSZ = virtual memory, RSS = physical memory
# If RSS grows continuously without stopping, it is a memory leak

Immediate Actions

# Find the most memory-hungry process
ps aux --sort=-%mem | head -5

# Restart it
sudo systemctl restart php8.2-fpm

# Clear filesystem cache (safe, non-destructive)
sync; echo 3 | sudo tee /proc/sys/vm/drop_caches

Prevention

  • Set PHP-FPM pm.max_requests to recycle workers and prevent leaks
  • Configure MySQL innodb_buffer_pool_size appropriately for available RAM
  • Add swap space as a safety net
  • Set up monitoring alerts for memory usage above 85%

Was this article helpful?