microsoft / microsoft/mimalloc
How to make sure mimalloc-override actually works?
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 13.4k
- Forks
- 1.2k
- Avg merge
- 4d 45m
- Merged PRs (30d)
- 13
Description
Hello,
Win10 x64, VS2022.
I'm building the mimalloc-override project and then I'm using this code in order to utilize it in my project (MFC-based application):
MimallocConnector.h
#pragma once
#include "..\mimalloc\include\mimalloc.h"
#ifndef _MFC_VER
// mimalloc explicit operator overloads conflict with MFC new/delete operators (linker
// errors), do not use explicit operator overloads in conjunction with MFC.
#include "..\mimalloc\include\mimalloc-new-delete.h"
#endif
MimallocConnector.cpp
#include "StdAfx.h"
#include "MimallocConnector.h"
#if defined(_WIN64)
#pragma comment(linker, "/include:ReferenceMimalloc")
#else
#pragma comment(linker, "/include:_ReferenceMimalloc")
#endif
extern "C" void ReferenceMimalloc(void)
{
const volatile int nVersion = mi_version();
}
Of course, mimalloc-override.dll and mimalloc-redirect.dll are copied into the build destination folder.
Then I'm using the minject --list in order to make sure mimalloc-override.dll is in the list, it actually is:
0: mimalloc-override.dll
1: mfc140u.dll
2: KERNEL32.dll
3: USER32.dll
4: GDI32.dll
5: ADVAPI32.dll
6: COMCTL32.dll
...
I'm running my program and it works just fine, I can see that mimalloc-override.dll and mimalloc-redirect.dll are loaded upon startup.
However, I don't underdstand how to make sure the standard library memory calls are actually redirected to mimalloc.
Doing something obvious like "void* p = malloc(100)", but the debugger does not go into the malloc, so I have no idea whether mimalloc is actually utilized.
Thank you.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Windows x64 setup using MimallocConnector.h and MimallocConnector.cpp, then inspect the loaded modules with minject --list. Investigate how the malloc call can be observed in this configuration and define a reliable check that confirms whether standard-library allocations reach mimalloc.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100