Search code examples
c#memorymemory-managementprofilingheap-dump

Analyzing Gigantic C# Heap Dumps (Over 10 GB)


I have seen this question before but the responses haven't scaled to my needs. I am looking for a way to analyze heap dumps from a C# application that uses an extremely high amount of memory.

One issue I run into is that the tool I am using is x86. This has been the case for a few appealing tools (VS2013 Ultimate, Antz memory profiler, PerfView).

I have also invested some time trying CLR Profiler but this does not seem to work (Edit - work when attached to the application).

Right now I feel my only other option would be to jump into Windbg. Are there any other tools that could support this?

Thanks!


Solution

  • I have used Windbg a lot. A DumpHeap -stat will give you good and fast results to check which objects are flooding over. If you are lucky you get from the call stacks a clue what is allocating so much data.

    Personally I like PerfView much better because it is much faster (it samples the heaps) and stores in the .gcDump file only a fraction of the data needed from the dump. You can take with PerfView a heap snapshot and ship this to the HQ which is much smaller than the original dump (factor 100 smaller usually). I have analyzed up to 36 GB dumps with PerfView with some issues but Vance Morrison was kind enough to help me out to fix his heap traversal code where a Stackoverflow occured.

    PerfView may be x86 but the internal HeapDumper which extracts the data from the dump is 64 bit of course.

    An alternative approach without any dumps is to enable in PerfView .NET Heap Sampl alloc tracing. This way you get call stacks for all allocations leading you directly to the code where allocations are happening.