Error Triage Hub (9)
Sidekiq Ruby glibc malloc Arena Bloat & Unbounded RSS Creep
Multi-threaded Ruby Sidekiq allocates separate 64 MB glibc arenas per thread and retains fragmented pages indefinitely without LD_PRELOAD jemalloc.
Telemetry: glibc RSS 3.8-6.4 GB vs jemalloc 1.3-1.9 GB
Why Sidekiq Memory Never Returns to Linux After Bursts
Default Debian/Ubuntu Ruby images link against glibc ptmalloc2, which creates up to 8x CPU-count memory arenas (64 MB virtual chunks) to avoid thread lock contention. Once Sidekiq threads spike during webhook imports or IMAP syncs, freed Ruby objects stay trapped in fragmented glibc arenas instead of returning to the OS.
Inspecting Arena Fragmentation via smaps and Sidekiq Stats
Compare Ruby live object heap (GC.stat[:heap_live_slots]) against container RSS in docker stats. When RSS exceeds 2.8 GB while Ruby heap reports under 450 MB, glibc arena fragmentation is burning 80%+ of your VPS memory.
Measured Thresholds & Configuration
| Allocator State | Sidekiq RSS (15 Threads) | Container Stability |
|---|---|---|
| Default glibc (Unbounded) | 3.8 - 6.4 GB steady creep | OOM Kill 137 every 12-48h |
| glibc + MALLOC_ARENA_MAX=2 | 2.4 - 3.3 GB plateau | Survives 8 GB nodes with swap guard |
| LD_PRELOAD libjemalloc.so.2 | 1.3 - 1.9 GB flat plateau | Zero arena leak across 30+ days |