Mimalloc v2.0.6 conflicts with Nvidia Nsight
Hello!
I found an issue while using mimalloc v2.0.6 and Nvidia Nsight. Here are the steps:
- You need an application with mimalloc integrated (D:/app.exe for example)
- Run it using Nvidia Nsight:

- In the debug configuration we get an assert:

- Here is the mimalloc output:

It looks like the problem is that Nvidia Nsight conflicts with mimalloc. Both are injected into the DLL load order to intercept the messages they need, and in this case Nsight is loaded first and prevents mimalloc from properly intercepting malloc/free calls.
Any thoughts on how this can be fixed?
Can you provide source code for mimalloc-redirect.dll so I can try to find some workaround or some good fix?
Ah I see. I cannot check this but if it is indeed the case that the insight dll is injected earlier than mimalloc, then you should try to move the mimalloc-redirect.dll earlier in the import table of the application. This can be done manually on the exe using tools like CFF explorer. However, if you get a recent version of dev-slice the bin directory contains the minject program that you can run on you executable to do this automatically. (run minject --help for options). This may fix the problem
Ah I see. I cannot check this but if it is indeed the case that the insight dll is injected earlier than mimalloc, then you should try to move the
mimalloc-redirect.dllearlier in the import table of the application. This can be done manually on the exe using tools like CFF explorer. However, if you get a recent version ofdev-slicethebindirectory contains theminjectprogram that you can run on you executable to do this automatically. (runminject --helpfor options). This may fix the problem
I already tried this and it didn't help :(
Mmm, I'll try to run Nvidia Nsight and try to see what is going on. I guess because nsight runs the application it injects it's dll earlier than anything else so it may be difficult to get around this... tbc
Just in case someone comes across this in the future, I managed to get redirection to work under Nsight Systems by using minject.exe on ToolsInjectionHelper64.dll (the DLL that gets injected by Nsight Systems). Of course this needs to be undone before launching an application which shouldn't use mimalloc.