Site icon New Generation Enterprise Linux

Catch the exact moment a process eats all your memory

Process & Resource Monitoring (Top/Htop/Ps/Systemd)

Catch the exact moment a process eats all your memory

🧩 The Challenge

Dealing with a production app that hits an OOM loop in the middle of the night is the absolute worst. You see the service dead the next morning, but have zero clues about what it was doing right before it choked.

💡 The Fix

Use systemd-run to launch your suspect processes with dedicated slice limits and have the kernel dump a core or trigger a specific event when they hit a memory ceiling. It keeps the rest of your server from catching the virus while you hunt down the leak.

systemd-run --scope -p MemoryMax=500M --user /path/to/your/flaky-app.sh

⚙️ Why It Works

Adding that memory constraint forces the system to either throttle or kill specifically that process rather than letting it cascade and take down your entire database or web server. It turns a mystery crash into a contained failure you can actually debug.

🚀 Pro-Tip: Pipe that to systemd-cat to log every stdout line directly to the journal without messing with log rotation files.

Linux Tips & Tricks | © ngelinux.com | 12/5/2026

0 0 votes
Article Rating
Exit mobile version