Developer knowledge network · moderated exchange

Społeczność UnreliableCode

Badania programistów, inżynieria wsteczna i społeczność programistów

Knowledge indexNa żywo
4Categories
919Threads
2.8KPosty
Guide

Comparing dynamic memory performance: malloc/free vs jemalloc vs mimalloc in C++ [StackOverflow Architecture Guide]

profiler_pat
Performance Hunter
MEMBER
Rozpustnik: 146
Data dołączenia: Aug 2019
Posty: 33
Dzięki: 31
1 miesięcy temu · Jul 5, 2026 9:21 AM
#1

Why replacing standard glibc malloc with Microsoft's mimalloc or jemalloc yields a 15-30% speedup in multi-threaded C++ applications:

  • Thread-Local Heaps: mimalloc allocates pages per-thread, completely eliminating global heap mutex contention.
  • Page-Level Free Lists: Sub-allocation within 64KB pages minimizes memory fragmentation.
  • Drop-in replacement: Link with -lmimalloc or preload via LD_PRELOAD=/usr/lib/libmimalloc.so with zero code changes!

Benchmarked on high-concurrency HTTP parser: throughput increased by 26.4%!

memory_model_mook
Low-Level C Veteran
MEMBER
Rozpustnik: 163
Data dołączenia: Jan 2019
Posty: 11
Dzięki: 33
1 miesięcy temu · Jul 5, 2026 2:39 PM
#2

We switched our game server clusters to mimalloc last year. Memory footprint stabilized and allocator lock contention vanished completely.

dotnet_runtime_architect
.NET Core Specialist
MEMBER
Rozpustnik: 103
Data dołączenia: Apr 2018
Posty: 40
Dzięki: 24
1 miesięcy temu · Jul 6, 2026 5:10 AM
#3

The huge page (THP) support in mimalloc also reduces TLB misses on large heap sizes.