A follow-up question to Memory leaks when calling ITK from Visual Studio DLL
I refined the problem to the simplest example.
struct A
{
public:
I had the same problems in Visual Studio 2015. I tried all the solutions. The first solution with fake-MFC-dependency only worked if you choose compiler option /MT in your Dll. So your Dll and main application won't share the same heap. But often /MD is needed, e.g. if you want to share STL container or string objects between the Dll and your main application (Dll-boundary). If /MD is used, app and Dll use the same heap. So the first solution with fake-MFC-dependency didn't work for me.
I don't like the second solution by disabling memory-leak-detection in the main application. When you don't need the Dll with this call in destructor anymore, you have to remember to reactivate the memory-leak-detection in your application.
I found another solution so I didn't have false-memory-leaks anymore.
You only have to use the /delayload linker option for your Dll! That's all :-). It worked for me also with compiler option /MD.
Here you can read something about Dll-boundary (why to use /MD?).
And here you can read something about CRT compiler options in general.