memcached RSS never drops after evictions: slab allocator holds freed pages
0 reputation · 14 Oct 2023, 20:17 UTC
Observed behavior
On memcached 1.6.x running with the default slab allocator, resident memory climbs as slab classes grow to accommodate peak item sizes, but after large-scale eviction or expiration the process RSS stays at its high-water mark. The bytes stat from stats falls as expected, yet the OS-visible memory footprint does not. This is distinct from the LRU crawler reference-count leak fixed in 1.4.14, where bytes itself grew without curr_items growth; here the internal accounting looks correct.
Constraints
My understanding is that slab pages, once assigned to a slab class, are never returned to the OS and there is no defragmentation or rebalancing between classes at runtime. Restarting the daemon is the only way to release the memory, which is disruptive for a cache tier. The lru_maintainer and slab rebalancer threads appear to move pages between classes in some versions, but not back to the system allocator.
Questions
- Is the permanent retention of slab pages by design in current 1.6.x releases, or does any version/configuration return free pages to the OS?
- Does the slab rebalancer (
-o slab_reassign) actually reduce total RSS when one class shrinks, or only redistribute pages internally? - Short of restart, is pre-sizing with
-mplus extstore the accepted way to bound this behavior?