title: How to dump the output of !dumpheap into a file, when the heap contains millions of objects?
body: <p>Please, observe:</p>
  
  <pre><code>0:000&gt; !dumpheap -stat
  Statistics:
                MT    Count    TotalSize Class Name
  000007fefa9c8c58        1           24 System.ServiceProcess.Res
  000007fef99d3de8        1           24 System.Collections.Generic.GenericArraySortHelper`1[[System.DateTime, mscorlib]]
  000007fef99cf8e8        1           24 System.Collections.Generic.GenericComparer`1[[System.Decimal, mscorlib]]
  ...
  000007fef8f02090    47295    141585288 System.Char[]
  000007fe9b1cbe20  1064155    229857480 Xyz.DataServices.Platform.BalanceTransactionForAccrualByOrg
  000007fef8f06888    21401    238104833 System.Byte[]
  000007fe9cd2efb8  1211503    358604888 Xyz.DataServices.Platform.AEBalanceTransaction
  0000000000386b30 11759620   1701611244      Free
  000007fef8e94918   777049   2352540408 System.Object[]
  000007fe9c4370e8 10571587   2621753576 Xyz.DB.DL.HREEmployeeManager
  000007fef8f00e08 131198125   1859306044 System.String
  Total 163792779 objects
  Fragmented blocks larger than 0.5 MB:
              Addr     Size      Followed by
  ...
  </code></pre>
  
  <p>Which means I have tens (hundreds?) of millions of objects on the heap. I would like to dump the information about them into a file.</p>
  
  <p>So <a href="https://stackoverflow.com/questions/33532692/how-to-redirect-windbg-command-to-a-file-without-echoing-the-output-on-the-windb">How to redirect windbg command to a file without echoing the output on the windbg console?</a> tells me the approach, but is it the best we can get when we are talking about tens (hundreds?) of millions of rows?</p>
  
  <p>I was wondering whether there is a programmatic API against which I could program to extract the data from the dump directly, rather than through WinDBG user interface. Or maybe there a plugin out there that already does it...</p>