microsoft / microsoft/mimalloc
How to disable mimalloc at runtime
- Dominant language
- C
- Stars
- 13.4k
- Forks
- 1.2k
- Avg merge
- 4d 45m
- Merged PRs (30d)
- 13
Description
Thanks for the great work. We managed to integrate mimalloc to our app and it works seamlessly.
However we have a requirement to disable mimalloc at application startup based on a condition and we couldn't find what would be the best way to do it.
MIMALLOC_DISABLE_REDIRECT=1 is not an option because we can't modify environment variables.
I'm basically looking for some code pointers that would let me intercept calls to mimalloc internal allocator and redirect to regular malloc/calloc/free/.. based on, let's say, a boolean. We'd like to do it with as minimum changes to mimalloc source as possible to avoid further maintenance costs when we update mimalloc version.
As an example, on OSX, I think returning early from zone registration function should disable mimalloc completely :
https://github.com/microsoft/mimalloc/blob/f2712f4a8f038a7fb4df2790f4c3b7e3ed9e219b/src/alloc-override-osx.c#L423
But I'm looking for a solution on Windows.
Any help is appreciated. Thanks in advance !
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue points to src/alloc-override-osx.c at the zone registration function; read that code first, then trace the Windows allocator override path in the repository. Done means identifying a supported startup-time way to choose between mimalloc and regular allocation without environment-variable changes, and documenting the relevant entry points.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- operating-systems, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100