microsoft / mimalloc

mimalloc is a compact general purpose allocator with excellent performance.
MIT License
9.74k stars 793 forks source link

Mimalloc attempts to allocate 33 MB shortly after thread start, prints spurious warning when it fails #823

Open Jarred-Sumner opened 8 months ago

Jarred-Sumner commented 8 months ago

On start when several threads are spawned, the following warning message is printed when using the debug build of mimalloc:

_mi_warning_message("unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x%zx bytes, address: %p, alignment: 0x%zx, commit: %d)\n", size, p, alignment, commit);

This warning message is not always actionable because (in this case) the developer didn't ask to allocate 33 MB. In my case, I care because it causes tests which read from stdout/stderr to fail.

Stepping through in a debugger, we can see the requested size is 64 bytes:

image

This is the stack trace:

image

When it reaches the warning, size & alignment seem to be 33,554,432:

image

Should this warning be silenced? Or does it point to a real problem and if so, what kinds of action can be taken (reduce the stack size of the application?)