I've been trying to identify a memory leak in my application. I made a dump file of the process and have been looking at it with windbg. When I do !dumpheap -stat and summarize the total usage of memory it totals at 1.6GB. But the process it self used almost 2.8GB when the dump was created. Can someone tell me where my missing 1.2GB are?
!dumpheap doesn't do what you might think. It dumps the managed heap, which is only a part of a .NET process. E.g. code in assemblies (both IL and JIT compiled code) aren't stored on the managed heap. Furthermore native assemblies allocate their own memory which doesn't show up on the managed heap either. As such you will never see the size of the managed heap match the size of the process. There's not a single place to look for the remaining memory usage. You might be able to get some additional insight by using vmmap.
Have you run an !address -summary or !heap -s? As Brian pointed out, !dumpheap only looks at the managed help.
I highly recommend grabbing Debug Diagnostics Tool 1.2 or 2.0 from Microsoft. Run it in Analysis Only mode, browse to your memory dump, fill in the crash/hang and managed memory analysis, and run it. The analysis is very useful and, in my opinion, less painful than using WinDbg. (I have used WinDbg off and on for over 10 years.)
Part of the analysis is a list of the unmanaged heaps. You can see these near the bottom of the report. Look for large ones, and see what DLL allocated them. In the past, this report helped me quickly identify a printer driver that had allocated over 1 GB of unmanaged space in a managed process!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With