Catch the exact moment a process eats all your RAM
Process & Resource Monitoring (Top/Htop/Ps/Systemd)
Catch the exact moment a process eats all your RAM
🧩 The Challenge
Dealing with a production server that hits 100 percent memory usage at 3 AM is a special kind of hell because by the time I log in, the OOM killer has already wiped the evidence. I’ve spent too many nights staring at empty logs trying to guess which runaway service caused the spike.
💡 The Fix
Use systemd to keep a running count of peak memory usage so the next time it happens, you don’t have to play detective. It puts a hard limit on the service and logs the actual usage right in the status output.
systemctl set-property your-service.service MemoryAccounting=yes MemoryMax=2G
⚙️ Why It Works
Setting MemoryAccounting forces the service manager to track resource usage for the cgroup, which lets you pull up current and peak stats anytime you want.
🚀 Pro-Tip: Run systemctl show your-service -p MemoryCurrent to see exactly how many bytes the process is holding right now.
Linux Tips & Tricks | © ngelinux.com | 9/5/2026
