murdering high-memory workers and auto-scaling

Eric Wong normalperson at
Fri Mar 2 01:20:16 UTC 2012

Ben Somers <somers.ben at> wrote:
> First: auto-killing bloated workers. My current app has some memory
> leakage that wasn't really visible on our older passenger setup, since

Btw, you reported issues with memory usage on a Ubuntu system
a few months ago, is this the same system?  Are you using stock
malloc() or tcmalloc()?  (tcmalloc comes standard with REE afaik
and never releases memory to the kernel).

For glibc malloc (ptmalloc) users I mentioned MALLOC_MMAP_THRESHOLD_,
but forgot about MALLOC_ARENA_MAX.

Since MRI is mostly single-threaded (especially the memory allocation
portions), I'm tending to think the per-thread optimizations in glibc
malloc do not help in most cases and will only lead to internal
fragmentation.  So perhaps setting MALLOC_ARENA_MAX=1 (perhaps along
with mmap threshold) in the environment will reduce fragmentation
and memory usage.

It doesn't look like the MALLOC_ARENA_* environment variables are
in the manpages, yet:

More information about the mongrel-unicorn mailing list