microsoft / microsoft/mimalloc

Override malloc in dynamically loaded dll on Windows

Open
#820 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

Dear all,

we're just trying to evaluate how to use mimalloc in a DLL project. We tried to use the dynamic override and used `minject.exe` to patch the dll load order to include mimalloc first. Unfortunately this whole approach is probably not suitable for our use case, because our DLL might be loaded dynamically be the user application (out of our control, we only supply the library). In that case we again get `mimalloc-redirect: error: mimalloc-redirect.dll seems to be initialized after ucrtbase.dll`, because the user application already loaded the CRT before loading our DLL dynamically.

What options do we have to use mimalloc in the Windows library anyway?

I had some issues with statically overriding a few years ago (https://github.com/microsoft/mimalloc/issues/268#issuecomment-870753622) and abandoned the mimalloc integration until now, but we again had some issues using the standard CRT allocator, so I'm trying to retry the integration now...

Best regards, Rainer

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the dynamic override workflow with minject.exe and the reported mimalloc-redirect.dll initialization error when ucrtbase.dll is already loaded. Then read the linked historical discussion about static overriding. Done means identifying a supported way to use mimalloc from a Windows DLL loaded dynamically by an external application.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.