http://www-d0.fnal.gov/d0dist/dist/releases/development/l3xDAQSuper/src/debug_utils/Source/memory_leak_checker.cpp // // memory_leak_checker.cpp // // This guy's constructor will start leak checking and when // its destructor is called it will print out error messages // if there is any memory that has been allocated. // #include "memory_leak_checker.hpp" #include <iostream>
// // ~memory_leak_checker // // Restore everything and print out the current state of // the memory heap. // memory_leak_checker :: ~memory_leak_checker (void) { #ifdef _DEBUG // // See if there is any difference between now and then. //
if (_filename_valid) { ::CloseHandle (_filename_handle); }
#endif }
// // break_on_block // // Cause a debugger break point when a certian block is allocated. // void memory_leak_checker::break_on_block (long block_number) { #ifdef _DEBUG _CrtSetBreakAlloc(block_number); _crtBreakAlloc = block_number;