In Visual Studio, when building debug releases, I seem to recall that memory leak detection was automatically enabled. In Visual Studio 2008, memory leak detection is not automatically enabled. Code will need to be added to the source files to make it available.
Memory Leak Detection Enabling
is a document in MSDN describing how to enable the ability. Basically, to enable the debug heap
functions, include the following statements:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
Immediately before the program exits, include the following function call:
_CrtDumpMemoryLeaks();
One commenter indicates that this only works best with C code, ie, C code will
get discriptive comments, but C++ code will get cryptic memory reports.
In order to get the file and line number to work you need to manually redefine new in your code.
This is done by undefining new, and redefining it to point to the debug versions that take a file and line number.
During debugging, in Windows based applications, std::cout no longer sends text into the
IDE's Output window. Instead, the function OutputDebugString( "..." ) needs to be used.