mimalloc <vs> default malloc

111.87.***.***
13

I've been testing C++20's pmr for quite a few days with both single-threaded and multi-threaded tests

Memory pooling works and the performance came out reasonably well, so I was thinking about continuing to use it, but...

Given the nature of a game engine that needs to squeeze every bit of hardware performance,

I realized that memory allocation performance can't just be "reasonably well"

So I decided to change it.

I thought about making one myself. I've made allocators before

using low-level APIs provided directly by the OS, and I could make one with appropriate features,

but that's like raising a cow just to make a hamburger patty...

So I decided not to go that far.

C++'s new is essentially memory allocation like malloc + constructor initialization call anyway,

so I decided to just swap out malloc.

The most famous ones are Facebook's jemalloc and Google's tcmalloc.

Both are well-known allocators with good performance and excellent optimization.

However, both are a bit heavy. They're full of all sorts of thread-local variables and caches...

The code isn't that complex, but still, I didn't like how heavy it was. hehe

Then I remembered mimalloc that Microsoft had released as open source...

I downloaded it and tested it.

Oh wow, it's indeed light, fast, and good.

I heard that mimalloc is the most popular these days, and it seems to be true.

I built it for both Windows and macOS, integrated it right away, and tested it.

For now, I only tested it on Windows.

sys_alloc is mimalloc.

The performance is great. In debug mode there are various check codes so it's slower, but...

When you do a Release build for real performance, it shows tremendous performance.

It shows performance comparable to the temp allocator used to make dynamic allocation zero when using STL.

It seems to perform the memory cache role very well internally.

Easy to compile, light, fast... and looking at various benchmark performance, even with large data throughput,

it still shows excellent performance, so I decided to use mimalloc!

After applying mimalloc and implementing new/delete, using C++20's std::source_location,

I also created a structure that tracks memory by recording the source code name, line, and function name of the corresponding call during allocation.

Now it seems I can just use this allocator uniformly whether making a server or a rendering engine.

로그인한 회원만 댓글 등록이 가능합니다.

개발한당

KR | ID | EN
  • IDR
  • KOR
8.34 0.01

2026.07.10 KEB 하나은행 고시회차 1271회

다가오는 한인 행사일정

  • 등록 된 일정이 없어요!