Friday, May 15, 2015

Memory leak tracking for the "new" operator

Add these code on the top of the file that you would like to track memory leak in.

#ifdef _DEBUG
   #ifndef DBG_NEW
      #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
   #endif
   #define new DBG_NEW
#endif  // _DEBUG

After that, debugger will displays memory leak information in the output window after the program finished.

No comments:

Post a Comment