METABYTE
Back to articles

mimalloc: Microsoft Reinvents the Wheel, but This Time It's Square and Very Fast

Microsoft releases mimalloc — a high-performance memory allocator that might speed up your code without the usual voodoo.

15 mai 20262 min read
mimalloc: Microsoft Reinvents the Wheel, but This Time It's Square and Very Fast

Microsoft Research has dropped a new memory allocator called mimalloc, promising speed, scalability, and readiness for modern workloads. If you thought malloc and its cousins were good enough, get ready to be impressed — or to roll your eyes, as usual.

What Is This Beast and How Do You Tame It?

mimalloc (short for 'microsoft memory allocator' — yes, they love long names) positions itself as a drop-in replacement for standard allocators in multi-threaded applications. It uses free list sharding and special optimizations for NUMA systems. In plain English: if your program frequently allocates and frees memory across threads, mimalloc can reduce overhead and boost performance.

The team claims mimalloc outperforms jemalloc, tcmalloc, and even glibc malloc, especially under high contention. They tested on real apps like Redis, MariaDB, and Apache, seeing 5% to 30% gains depending on the workload. Sounds like marketing? Possibly. But they have benchmarks, so let's not jump to conclusions.

How It Works (TL;DR for the Impatient)

  • Free list sharding: Instead of one global free list, mimalloc uses per-thread local lists, reducing contention.
  • Lazy coalescing: Freed blocks aren't immediately returned to the global pool but stay in local caches, speeding up reallocation.
  • NUMA-aware: The allocator respects memory topology, trying to allocate memory on the same node as the thread.

This resembles jemalloc's approach but with improvements — especially page-based management and a small footprint.

Should You Switch?

If your app suffers from memory allocation bottlenecks (e.g., high time in malloc/free), give it a try. mimalloc is already used in .NET Core and Azure. And yes, it's open source (MIT), so you can LD_PRELOAD it or link statically. But remember: the devil's in the details, and not all allocation patterns benefit equally.

METABYTE studio's take: We love chasing performance too, but we usually start with profiling, not swapping allocators. Still, mimalloc is a great tool for squeezing extra FPS from your game engine or high-load server. Just test on real data, not synthetic benchmarks, or you might end up with 'faster' tests and slower production.

NEXT STEP

Liked the approach?

We apply the same principles to client projects: AI, automation, products that don't die after launch.