1 #ifndef MEMORY_LEAK_TRACKER_H
2 #define MEMORY_LEAK_TRACKER_H
7 #define USE_MEMORY_TRACKING
10 #ifdef USE_MEMORY_TRACKING
14 #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
15 #define new DEBUG_CLIENTBLOCK
17 extern _CrtMemState mem_state;
19 #define SET_CRT_DEBUG_FIELD(a) \
20 _CrtSetDbgFlag((a) | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
22 inline void DebugDumpMemory()
24 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
25 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
26 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
31 SET_CRT_DEBUG_FIELD(_CRTDBG_LEAK_CHECK_DF);
33 _CrtMemCheckpoint(&mem_state);
36 atexit(DebugDumpMemory);
39 #else // USE_MEMORY_TRACKING
40 #define DEBUG_CLIENTBLOCK
43 #endif // USE_MEMORY_TRACKING