CRT Memory Leak checker fails - I'm afraid

Started by
4 comments, last by Drakonite 13 years, 8 months ago
Hi..

I just noticed that C++'s CRT Leak Checker doesn't check for leaks anymore. Now I don't know how long has it been like this and if it's a long time I guess I have some memory leaks to get fixed. But to do this, I need to get that leak-checker running, here is what worked before:

//Before something gets included:#if defined(DEBUG) | defined(_DEBUG)#define _CRTDBG_MAP_ALLOC#endif


//Right after WinMain() started#if defined(DEBUG) | defined(_DEBUG)    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );#endif


But putting this at the end of WinMain() nothing gets logged!
	int* i=new int[5];    return DXUTGetExitCode();}



Someone sees the issue?
Advertisement
Are you sure you are linking against the debug version of the CRT? Are you sure you are doing a debug build and that _DEBUG is defined? Are you running inside of Visual Studio or launching the application directly?
Shoot Pixels Not People
Quote:Are you sure you are doing a debug build and that _DEBUG is defined? Are you running inside of Visual Studio or launching the application directly?


These two: Yes, I'm sure.

But this...
Quote:
Are you sure you are linking against the debug version of the CRT?


Where do I see if I am or not? Currently I'm linking to
kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;andd3d11.lib DXGI.lib libfftw3-3.lib D2D1.lib dwrite.lib windowscodecs.lib libogg_static.lib libvorbisfile_static.lib libvorbis_static.lib Audiere.lib dwmapi.lib dxerr.lib dxguid.lib d3dx9d.lib d3d9.lib d3dx11d.lib winmm.lib comctl32.lib assimp.lib d3dcompiler.lib 


I don't see anything CRTish there... However, I think I won't see if its a debug version or not there.
If you open your project properties, go to C/C++, and then Code Generation, this is the option Runtime Library.

IIRC leak tracking only works with the debug versions. Default project settings use a debug version for debug builds and release version for release builds, but it can be changed -- and I think requires changing to link certain external libraries that do not include debug versions.
Shoot Pixels Not People
There it says "Multi-threaded Debug DLL (/MDd)"... Now what?
Sorry, without having the project in front of me I don't have any major ideas.

The next things I'd check are if those bits of code are actually being compiled/called, and then whether anything conflicts with them.

At a quick look it appears you are using DXUT, and it may be calling some of the crt debug stuff itself.
Shoot Pixels Not People

This topic is closed to new replies.

Advertisement