DH Topics | Previous

DH Usage Scenario


When setting up development practices for a new project, many developers like to use a common memory allocation routine, exposed as a macro, which can easily be switched to use a memory leak-tracking version. When the process ends, this memory leak-tracking version dumps any remaining allocated memory chunks, usually stored in a linked list, along with the file name and line-number information on where each allocation was made.

Older projects may not have planned for such memory leak-tracking features. In this case, you can use Dh.exe to dump all memory allocations at a beginning point in the test program to a file (Dh_1.dmp, for example), run the stress application for some time, have the stress program pause in a state that should be identical to the first pause, then take another reading with Dh.exe (Dh_2.dmp).

With the two output files, Dh_1.dmp and Dh_2.dmp, you can then use Dhcmp.exe to compare them for any changes in memory usage. Dhcmp.exe will list any memory allocation differences in order of size and tells you a block number for each leak. For each block number, look in the file Dh_2.dmp and go to each allocation history to see a stack back-trace which tells you what chunks of memory are not being freed correctly.