Developer knowledge network · moderated exchange

مجتمع الكود غير الموثوق به

أبحاث المطورين، مجتمع الهندسة العكسية والترميز

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 months ago · 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 months ago · 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 months ago · Jul 6, 2026 5:10 AM
#3

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