Developer knowledge network · moderated exchange

Супольнасць UnreliableCode

Супольнасць распрацоўшчыкаў даследаванняў, зваротнага праектавання і кадавання

Knowledge indexжыць
4Categories
919Threads
2.8KПаведамленні
Guide

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

profiler_pat
Performance Hunter
MEMBER
прадстаўнік: 146
Дата далучэння: Aug 2019
Паведамленні: 33
Дзякуй: 31
1 месяцаў таму · 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
прадстаўнік: 163
Дата далучэння: Jan 2019
Паведамленні: 11
Дзякуй: 33
1 месяцаў таму · 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
прадстаўнік: 103
Дата далучэння: Apr 2018
Паведамленні: 40
Дзякуй: 24
1 месяцаў таму · Jul 6, 2026 5:10 AM
#3

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