Skip to main content
READY SIDEKIQHEAP TRIAGE // AMBER TRIAGE HUD TARGET: PUMA + SIDEKIQ JEMALLOC | REDIS NOEVICTION | INTERCOM EXIT
ChatwootQueues
ChatwootQueues Partner Notice: Outbound /go/ links marked rel="sponsored" may earn a referral fee at zero checkout surcharge (Disclosures).
Remediation Hub (9)

Tune MALLOC_ARENA_MAX=2 & Ruby GC Slots When Using glibc

If custom base images lack libjemalloc, setting MALLOC_ARENA_MAX=2 prevents 8x core arena multiplication across Sidekiq worker threads.

Env: MALLOC_ARENA_MAX=2 | Relief: -30% to -45% glibc overhead

Tune MALLOC_ARENA_MAX=2 & Ruby GC Slots When Using glibc
Telemetry verified 2026-10-31 by SidekiqHeap Triage.

When MALLOC_ARENA_MAX=2 Acts as an Immediate Guardrail

If you run an older Chatwoot build or custom distro without jemalloc compiled in, glibc defaults to 8 * vCPU arenas. Setting MALLOC_ARENA_MAX=2 forces threads to share two arenas, trading negligible allocator lock contention for hundreds of megabytes of saved virtual memory.

Pairing MALLOC_ARENA_MAX with RUBY_GC_HEAP_GROWTH_FACTOR

Set RUBY_GC_HEAP_GROWTH_FACTOR=1.15 and RUBY_GC_MALLOC_LIMIT=16777216 so Ruby triggers minor/major sweeps earlier before large webhook JSON hashes inflate RSS. Remove MALLOC_ARENA_MAX once jemalloc is active via LD_PRELOAD.

Measured Thresholds & Configuration

Environment VariableRecommended ValueEffect on Ruby Process
MALLOC_ARENA_MAX2Caps glibc arenas (fallback without jemalloc)
RUBY_GC_HEAP_GROWTH_FACTOR1.15Shrinks post-GC heap expansion steps
RUBY_GC_MALLOC_LIMIT16777216Triggers GC sooner after C-ext allocations
Env: MALLOC_ARENA_MAX=2 | Relief: -30% to -45% glibc overhead Deploy Hostinger KVM 4Vultr Cloud 8 GB ($40/mo)