How Do I Use the User-Mode Dump Heap (UMDH) to Debug Magic xpi? (Magic xpi 3.x)
Memory leaks can be hard to trace. Microsoft has provided developers with a useful utility that works with the operating system to analyze Windows heap allocations for a specific process.
This utility, called UMDH (User-Mode Dump Heap) is part of the Debugging Tools for Windows. The general usage would be to take a snapshot of the memory state in a "quiet mode", reproduce the memory leak and take another snapshot, and then compare the two shots.
To use the User-Mode Dump Heap (UMDH) to debug Magic xpi, follow these steps:
Download a copy of the Debugging Tools for Windows from:
You should download a file called dbg_x86_22.214.171.1243.msi.
Open a command prompt and open the Debugging Tools for Windows installation directory, usually %ProgramFiles%\Debugging Tools for Windows\ (in a 64bit OS you need to add the "(*86)").
Define an environment variable _NT_SYMBOL_PATH to point to the directory of the pdb files.
Enable the user stack trace: gflags -i +ust
Note: You can also do this via the global flags UI.
Start the runtime engine. Then run the Magic xpi application/server.
Reach a starting point. After running the executable, go through tasks that you plan to use again.
Make a snapshot, calling the file begin.txt:
umdh -p: -f:
For example: umdh -p:1234 -f:d:\temp\begin.txt
Run the same programs a few more times to create a memory leak, and then reach the same open windows state that existed when you ran the first snapshot.
Again, create a snapshot, this time called end.txt:
umdh -p:1234 -f:d:\temp\end.txt (This is a different file this time.)
Now run a comparison between the files:
umdh -d d:\temp\begin.txt d:\temp\end.txt -f:d:\temp\diff.txt
Send the diff.txt.
Disable the user stack trace: gflags -i -ust