Hauptseite | Klassenhierarchie | Auflistung der Klassen | Auflistung der Dateien | Klassen-Elemente | Datei-Elemente | Zusätzliche Informationen

CheckMemory.h

gehe zur Dokumentation dieser Datei
00001 // Makros zum Aufspüren von MemoryLeaks 00002 00003 #ifndef _XCTL_CHECKMEMORY_H_ 00004 #define _XCTL_CHECKMEMORY_H_ 00005 00006 #include <crtdbg.h> 00007 00008 00009 //Memory states 00010 _CrtMemState s1, s2, s3; 00011 00012 00013 // This routine place comments at the head of a section of debug output 00014 void OutputHeading( const char *explanation ) 00015 { 00016 _RPT1( _CRT_WARN, "\n\n-----%s----------------------------------------\n", explanation ); 00017 } 00018 00019 // This routine place an end-comment at the head of a section of debug output 00020 void OutputEnd() 00021 { 00022 _RPT0( _CRT_WARN, "\n---------------------------------------------\n\n"); 00023 } 00024 00025 // This routine checks memory and place comments at the head of a section of debug output 00026 void CheckMemory(const char *explanation) 00027 { 00028 OutputHeading(explanation); 00029 _CrtDumpMemoryLeaks(); 00030 OutputEnd(); 00031 } 00032 00033 // This routine saves pre-execution memory state 00034 void SavePreState() 00035 { 00036 _CrtMemCheckpoint(&s1); 00037 } 00038 00039 // This routine saves post-execution memory state 00040 void SavePostState() 00041 { 00042 _CrtMemCheckpoint(&s2); 00043 } 00044 00045 // This routine dumps difference between pre- and post-execution memory state 00046 void DumpMemoryState(const char *explanation) 00047 { 00048 if (_CrtMemDifference(&s3,&s1,&s2)) 00049 { 00050 OutputHeading(explanation); 00051 _CrtMemDumpStatistics( &s3 ); 00052 OutputEnd(); 00053 } 00054 } 00055 00056 // This routine dumps all objects instantiated since pre-execution memory state 00057 void DumpMemoryObjects(const char *explanation) 00058 { 00059 OutputHeading(explanation); 00060 _CrtMemDumpAllObjectsSince( &s1); 00061 OutputEnd(); 00062 } 00063 00064 00065 // 00066 #ifdef _DEBUG 00067 #define CHECKMEM(a) CheckMemory(a) 00068 #define PRE SavePreState() 00069 #define POST SavePostState() 00070 #define DUMPDIFF(a) DumpMemoryState(a) 00071 #define DUMPMEM(a) DumpMemoryObjects(a) 00072 #else 00073 #define CHECKMEM(a) 00074 #define PRE 00075 #define POST 00076 #define DUMPDIFF(a) 00077 #define DUMPMEM(a) 00078 #endif //_DEBUG 00079 00080 #endif //_XCTL_CHECKMEMORY_H_ 00081

Erzeugt am Sat Nov 13 12:48:04 2004 für XCTL32 von doxygen 1.3.7