C/C++ Programming - Windows Memory Leak Analysis using DebugDiag

DebugDiag one of the simple tools which has helped me in analyzing memory leaks for Windows. Once we enable the tracker to monitor for memory pressure analysis we can generate memory dumps for corresponding process and do an Analysis to get the stack trace, allocation count and memory leak probability. We can also get the dependent DLL specific memory as well, which helps in narrowing down issue to a module.

Following are the steps which i follow during analysis of a memory leak issue on windows using the debugdiag.

  1. build the binary or module in debug mode

  2. make sure that binary/module PDB file is also generated. Which can be enabled by using /PDB option of link.exe.

  3. deploy the debug binary along with PDB file on the env on which we have to do the analysis

  4. start the process (supposing that this would be a server class program)

  5. start DebugDiag and select the server app to be tracked for "Memory and Handle Leak"

  6. keep doing the operation which results in memory leak for few hours

  7. Under "Processes" tab within DebugDiag right click the server program and select "Create Full Memory Dump"

  8. Then do the analysis using that data file. (How to use the Debug Diagnostics 1.0 tool to analyze a memory dump file)

NOTE: Make sure that the symbol directory configured for DebugDiag points to the folder which contains the necessary PDB files. The folder to search for symbol files can be configured using Tools->Options and Settings->Symbol Search Path For Analysis

Labels: , , ,

About this entry