Stop cgroups from eating your memory without warning
Container Basics On Linux (Namespaces/Cgroups)
Stop cgroups from eating your memory without warning
🧩 The Challenge
Dealing with a container that suddenly starts OOM killing processes inside itself is a massive headache. You think you set the limit right, but the kernel just starts nuking everything because you forgot about the page cache.
💡 The Fix
You have to tune the memory.low or memory.min settings in your cgroup v2 controller to actually reserve some breathing room for the application. It stops the kernel from being so aggressive when memory pressure hits.
echo 100M > /sys/fs/cgroup/my_app/memory.min
⚙️ Why It Works
Setting memory.min forces the kernel to protect that specific amount of memory from being reclaimed, which prevents the container from thrashing when the filesystem cache starts ballooning. It turns a silent disaster into a stable runtime.
🚀 Pro-Tip: Always check memory.stat to see if your cache is actually what’s driving your pressure spikes before you just throw more RAM at the container.
Linux Tips & Tricks | © ngelinux.com | 8/7/2026
