#ifndef _SP_COMM_H__ #define _SP_COMM_H__ #define _CRTDBG_MAP_ALLOC #include #ifdef RVC_OS_WIN #include #endif //RVC_OS_WIN #include #include #include #include "SpBase.h" namespace SP { /** Leak Detector*/ namespace Perf { struct LeakDetector { LeakDetector() { #if defined(RVC_OS_WIN) && defined(WITH_DEBUG) int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); flag |= _CRTDBG_LEAK_CHECK_DF; flag |= _CRTDBG_ALLOC_MEM_DF; _CrtSetDbgFlag(flag); #endif //defined(RVC_OS_WIN) && defined(WITH_DEBUG) } ~LeakDetector() { } }; struct LineLeakDetector { LineLeakDetector() { #if defined(RVC_OS_WIN) && defined(WITH_DEBUG) _CrtMemCheckpoint(&s1); #endif //defined(RVC_OS_WIN) && defined(WITH_DEBUG) } ~LineLeakDetector() { #if defined(RVC_OS_WIN) && defined(WITH_DEBUG) _CrtMemCheckpoint(&s2); if (_CrtMemDifference(&s3, &s1, &s2)) _CrtMemDumpStatistics(&s3); //_CrtDumpMemoryLeaks(); #endif //defined(RVC_OS_WIN) && defined(WITH_DEBUG) } #if defined(RVC_OS_WIN) && defined(WITH_DEBUG) _CrtMemState s1, s2, s3; #endif //defined(RVC_OS_WIN) && defined(WITH_DEBUG) }; } } #ifndef ASSERT #include #define ASSERT assert #endif #endif // _SP_COMM_H__