jemalloc
A general-purpose malloc implementation focused on fragmentation avoidance and concurrency.
Recommended as a drop-in replacement for glibc malloc that sharply cuts memory use in Rails, Sidekiq, Python and JVM services,12345 and valued for per-thread allocation counters.6 The main caveat is that it can need tuning, such as oversize_threshold in containers to avoid OOM kills.7
Why people recommend it
Lower memory use · 3
Switching from the default allocator cut memory dramatically, in some cases from 8–10GB to under 1GB.
“I switched to jemalloc on a sidekiq queue and memory dropped from 8gib to under 1gib”
“Switched to jemalloc and instantly memory stayed well below 1GB.”
Show 1 more
“We migrated to jemalloc from glibc malloc two years ago and saw 15-20% memory reduction in our Python services.”
Fewer OOM kills · 2
Switching made out-of-memory kills and unreleased memory problems go away.
“some of the services switched to jemalloc for the Java VM.”
“Switched to jemalloc and instantly memory stayed well below 1GB.”
Runtime performance · 1
A good malloc can improve a JVM's CPU and memory performance noticeably.
“Providing your JVM with a good malloc can improve the performance of the runtime, both in terms of CPU and memory, by quite a bit.”
Per-thread counters · 1
Per-thread allocation counters allow tracking and enforcing per-thread memory budgets, unlike tcmalloc or mimalloc at the time.
“I use Jemalloc on a project because it has per-thread allocation counters.”
Caveats and dissent
Needs tuning · 1
oversize_threshold had to be tuned carefully for containerized workloads to avoid OOM kills.
“We migrated to jemalloc from glibc malloc two years ago and saw 15-20% memory reduction in our Python services.”
Not default · 1
It must be enabled explicitly rather than coming as the default allocator.
“I used jemalloc recently for ComfyUI/Wan and it’s literally magic.”
Often compared with
Who recommends it in their own words
Threads where it came up
- Jemalloc 5.4.0 5 mentions
- Jemalloc un-abandoned by Meta 3 mentions
Data: jemalloc.json. Quotes are verbatim; the verdict and theme labels are written by a model from these comments, and every clause links to its sources.
All comments 8
“Jemalloc is great for Ruby on Rails apps, and drastically reduces memory usage for the same workloads.”
“I use Jemalloc on a project because it has per-thread allocation counters.”
“Switched to jemalloc and instantly memory stayed well below 1GB.”
“I switched to jemalloc on a sidekiq queue and memory dropped from 8gib to under 1gib”
“Providing your JVM with a good malloc can improve the performance of the runtime, both in terms of CPU and memory, by quite a bit.”
“We migrated to jemalloc from glibc malloc two years ago and saw 15-20% memory reduction in our Python services.”
“I used jemalloc recently for ComfyUI/Wan and it’s literally magic.”
“some of the services switched to jemalloc for the Java VM.”