Visual Studio debug tools to detect and debug memory leaks by setting a breakpoint on a particular memory allocation.


/ Published in: C++
Save to your folder(s)

The Visual Studio output window will display "Detected memory leaks!" with a memory allocation number, for example, {145}. See Memory Leak Detection Enabling.

Using the debugger (without changing code) see: http://msdn.microsoft.com/en-us/library/w2fhc9a3%28VS.80%29.aspx


Copy this code and paste it in your HTML
  1. // Using the debugger (without changing code) see: http://msdn.microsoft.com/en-us/library/w2fhc9a3%28VS.80%29.aspx
  2.  
  3. // Includes...
  4. #define _CRTDBG_MAP_ALLOC
  5. #include <stdlib.h>
  6. #include <crtdbg.h>
  7.  
  8.  
  9. // Set this debug flag
  10. _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
  11.  
  12. // break on a particular allocation as indicated in visual studio as {145}.
  13. _crtBreakAlloc = 145;

URL: http://msdn.microsoft.com/en-us/library/w2fhc9a3%28VS.80%29.aspx

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.