Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li>Enable Unmanaged Debugging in the "Debug" tab of your project properties</li> <li>Run the application and set a breakpoint at a point where you want to investigate the types</li> <li>In the <em>Immediate</em> window, type:</li> </ol> <pre><code>.load sos !DumpHeap -type &lt;partial type name&gt; </code></pre> <p>This will return something like:</p> <pre><code> Address MT Size 026407c0 53ecee20 16 </code></pre> <p>Then you can take the <code>Address</code> and use <code>GCRoot</code> to find the where it's rooted:</p> <pre><code>!GCRoot 026407c0 </code></pre> <p><a href="http://www.lovettsoftware.com/blogengine.net/post/2010/01/15/Visualizing-Runtime-Object-Graphs.aspx" rel="noreferrer">Chris Lovett</a> (via <a href="http://blogs.msdn.com/b/tess/archive/2010/03/03/tool-for-generating-dgml-graphs-showing-why-your-object-can-t-be-collected-visualgcroot.aspx" rel="noreferrer">Tess Ferrandez</a>) created a very neat utility that converts the low-level <code>GCRoot</code> output into a DGML graph which might make it easier to diagnose.</p> <p>Alternatively, Mohamed Mahmoud created a <a href="http://blogs.msdn.com/b/mohamedg/archive/2010/03/02/visual-gcroot-via-dgml.aspx" rel="noreferrer">debugger extension</a> that enables you generate the graph from WinDBG, but it doesn't work within Visual Studio so you might want to stick to Chris's utility to avoid installing the Debugging Tools.</p> <p>Having said that, the textual output may well be enough for you to track things down. If you want information on the output of GCRoot, type <code>!help GCRoot</code> in the immediate window.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload