You can also add
Code:
#ifdef _DEBUG
#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
#else
#define DEBUG_CLIENTBLOCK
#endif
to a header that's included everywhere (stdafx.h perhaps) and
Code:
#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif
as early as possible in every cpp-file and in main
Code:
int main()
{
#if defined(_DEBUG)
int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
tmpFlag |= _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF; // Check heap alloc and dump mem leaks at exit
_CrtSetDbgFlag( tmpFlag );
assert( !errno );
//_crtBreakAlloc = 58652; // Set to break on allocation number in case you get a leak without a line number
#endif
...
This will make every single leak to be detected regardless where it occur