#668·mimalloc

Resolving `mimalloc-redirect.dll` seems to be initialized after `ucrtbase.dll`

Author: jeremyongCreated Dec 15, 2022Updated Sep 20, 2026
Labelsstale

At application start, I am seeing the following output:

mimalloc-redirect: error: mimalloc-redirect.dll seems to be initialized after ucrtbase.dll   
  (hint: try to link with 'mimalloc-override.lib' earlier on the command line?)
mimalloc-redirect: error: mimalloc-redirect.dll seems to be initialized after ucrtbased.dll  
  (hint: try to link with 'mimalloc-override.lib' earlier on the command line?)
mimalloc-redirect: warning: standard malloc is _not_ redirected! -- using regular malloc/free

The executable spawning these messages is linking mimalloc.lib (this is the mimalloc.dll import lib) as well as mimalloc-redirect.lib (the import lib for mimalloc-redirect.dll). Both of the DLLs are in the executable directory (of course, or nothing would run at all). Care was taken to ensure these libs appear first in the linker input list.

I have even tried declaring a static variable like so:

static int mv = mi_version();

in an attempt to force the mimalloc DLLs to load early, albeit to no avail. Running the exe under WinDbg, I'm finding the ModLoad of mimalloc.dll and the associated mimalloc-redirect.dll far too late, after other DLLs and ucrtbased.dll is loaded. After playing around with this a bit, I'm convinced that changing the ordering of the linker inputs appears to do little to influence the actual DLL loading order (latest MSVC at the time of this writing, Windows 10).

I did confirm that allocations are properly being redirected to mimalloc's allocation and deallocation routines however, immediately after entry into main (mimalloc's DllMain runs first, resulting in the messages above).

Do you have any suggestions on how to properly use the redirect DLL? Thanks!