Site icon New Generation Enterprise Linux

Stop the cgroup v2 memory leak when your pods keep scaling

Container & Kubernetes Internals

Stop the cgroup v2 memory leak when your pods keep scaling

Technical Briefing | 12/1/2026

Most of us moved to cgroup v2 without thinking about the transition, assuming the kernel would handle the accounting just like it did in v1. That is usually true until your Kubernetes nodes start showing ghost memory usage that does not align with your container stats. I have spent too many mornings chasing down nodes that report high pressure while the actual processes claim they are well within their limits. It usually comes down to how the kernel accounts for cached objects when you frequently kill and spawn short-lived pods.

Why the kernel keeps holding onto your dead pods

The issue is the slab cache. In cgroup v2, the kernel tracks memory used by filesystem metadata, like dentries and inodes, per cgroup. When a pod terminates, its cgroup is marked for deletion, but if there are still active kernel objects referencing those files, the memory accounting sticks around. These orphans are invisible to kubectl top and standard metrics scrapers. Over time, these un-reclaimable slabs pile up until your OOM killer starts acting on phantom memory that isn’t even tied to a running process anymore.

echo 3 > /proc/sys/vm/drop_caches
  • Check your current slab consumption with slabtop or /proc/slabinfo
  • Look for the cgroup-specific objects that remain after a pod is gone
  • Consider lowering vfs_cache_pressure if your workload has high churn
  • Verify your kernel version because some older 5.x releases had severe slab leak bugs

Finding the culprit before the node panics

You can dig into the memory stats of the dead cgroup if you still have the path. Peek into memory.stat under your pod’s cgroup slice on the host. If you see high numbers for slab_reclaimable or slab_unreclaimable even after the process tree is empty, you have found the leak. If you have to resort to dropping caches in production, do it during low-traffic windows because it forces a global re-read of the page cache, which will spike your disk I/O latency for a few seconds. It is a blunt instrument, but when the node is teetering on a kernel panic, you take what you can get.

Linux Admin Automation  |  © www.ngelinux.com  |  12/1/2026
0 0 votes
Article Rating
Exit mobile version