Umdh.exe - A Relatively Unknown Tool
Most investment bank software engineers don't know about Microsoft's Umdh.exe. UMDH is included with the Debugging Tools for Windows product, and provides Windows heap analysis - very useful for looking for memory leaks. We found UMDH particularly useful in tracking down a memory leak in a trading application that used Visual C++ (managed/unmanaged) code and C#.
Prior to running Umdh.exe on a Windows process, ensure the environment variable _NT_SYMBOL_PATH is set. Also, turn on stack tracing using: 'gflags -i <AppName> +ust' to get output like this:
000002E8 bytes by: BackTrace11817
ntdll!RtlDebugAllocateHeap+000000E1
ntdll!RtlAllocateHeapSlowly+00000041
ntdll!RtlAllocateHeap+00000E44
KERNEL32!LocalAlloc+00000058
mscorwks!operator new+00000017
mscorwks!Thread::RedirectThreadAtHandledJITCase+0000001B
mscorwks!Thread::SysSuspendForGC+000000E4
mscorwks!GCHeap::SuspendEE+000000CF
mscorwks!GCHeap::GarbageCollectGeneration+00000103
mscorwks!gc_heap::allocate_more_space+0000013A
mscorwks!GCHeap::Alloc+00000064
mscorwks!Alloc+0000003A
mscorwks!FastAllocatePrimitiveArray+00000045
mscorwks!JIT_NewArr1+000000BB
system.xml!??? @ 7BD760DD
UMDH allows log file comparison, allowing easy identification of what memory allocations occurred between two points in time:
//
// Each log entry has the following syntax:
//
// + BYTES_DELTA (NEW_BYTES - OLD_BYTES) NEW_COUNT allocs BackTrace TRACEID
// + COUNT_DELTA (NEW_COUNT - OLD_COUNT) BackTrace TRACEID allocations
// ... stack trace ...
//
// where:
//
// BYTES_DELTA - increase in bytes between before and after log
// NEW_BYTES - bytes in after log
// OLD_BYTES - bytes in before log
// COUNT_DELTA - increase in allocations between before and after log
// NEW_COUNT - number of allocations in after log
// OLD_COUNT - number of allocations in before log
// TRACEID - decimal index of the stack trace in the trace database
// (can be used to search for allocation instances in the original
// UMDH logs).
//
+ 5d0 ( 8b8 - 2e8) 3 allocs BackTrace11817
+ 2e8 ( 5d0 - 2e8) 2 allocs BackTrace11819
I'm unsure if this was an issue with my install, but whenever System.xml appeared in the stack trace, there was always a ???? for the function name (possibly due to the call being managed code):
VaDump is another utility that appears useful. Does anyone have any experience of VaDump?