Stop watching your memory limit kill your container without a trace
Container Basics On Linux (Namespaces/Cgroups)
Stop watching your memory limit kill your container without a trace
🧩 The Challenge
Dealing with a container that silently dies because it hit its memory ceiling is enough to make you pull your hair out. You check the logs and see absolutely nothing, which usually means the OOM killer stepped in before the app even had a chance to log a stack trace.
💡 The Fix
Instead of guessing why your service keeps flapping, you can check the memory controller status directly in the cgroup filesystem to see the exact peak usage and failure counts. It saves you from digging through dmesg for a needle in a haystack.
cat /sys/fs/cgroup/memory/docker/<container-id>/memory.failcnt
cat /sys/fs/cgroup/memory/docker/<container-id>/memory.max_usage_in_bytes
⚙️ Why It Works
Accessing the memory.failcnt file lets you see how many times the process tried to exceed its limit, while memory.max_usage_in_bytes tells you exactly how much RAM it actually grabbed before getting smacked down by the kernel.
🚀 Pro-Tip: Run this while your container is still flapping to catch the spike before the cgroup gets wiped on exit.
Linux Tips & Tricks | © ngelinux.com | 10/16/2026
