Tracking memory leaks in Visual Studio

I just discovered this useful piece of code for all who don’t have (including me) any memory leaks tracking code or software. I know there are other and better solution but this can be handy for quick findings without much hassle. First place this code in your entry point file, generally main.cpp inside your main() function #ifdef _DEBUG int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); flag |= _CRTDBG_LEAK_CHECK_DF; // Turn on leak-checking bit _CrtSetDbgFlag(flag); #endif Now just run you game/program as you would normally, in debug mode of course. ...

October 19, 2010 · 1 min · 165 words · David Amador