none
Interpreting the result of !gcroot command in WinDBG/SOS

    Question

  • I am trying to track down what's holding my object hostage by attaching WinDBG/SOS to my app and running !gcroot on an address returned by !dumpheap.

    I am at a loss as to how to interpret the result of !gcroot output.  I'm including the result here - perhaps someone can help me understand what it is saying.
    I think most of the references are weak references (short and long) and I probably shouldn't have to worry about them but there is one that says Pinned, I am wondering if that's what's causing it to stay alive.  The object I'm tracking is called PnlConfigView and it's a windows forms User Control.  The one that seems to be holding onto it is LoadWaitControl which is very simple windows forms custom control (label and a progress bar).  At some point during the app, LoadWaitControl will add itself as a child control to PnlConfigView and then remove itself short time later.  As far as I can see, everything is clean - it gets added and removed properly.

    If you anyone also know, any documentation or tutorial on !gcroot, especially in the context of Windows Forms application, please let me know.  I've found some out there but they mostly focus on the steps but not on the details of the output of each command, etc.  (including MSDN link here: http://msdn.microsoft.com/en-us/library/bb190764.aspx)

    Thanks!

    Note: Roots found on stacks may be false positives. Run "!help gcroot" for
    more info.
    Scan Thread 0 OSTHread 12d0
    Scan Thread 2 OSTHread da0
    Scan Thread 3 OSTHread 14dc
    Scan Thread 5 OSTHread 1188
    Scan Thread 6 OSTHread 12c0
    Scan Thread 8 OSTHread 1748
    Scan Thread 9 OSTHread 1588
    Scan Thread 10 OSTHread 1458
    Scan Thread 16 OSTHread 150
    Scan Thread 17 OSTHread 13bc
    DOMAIN(001537B0):HANDLE(WeakSh):a01200:Root:014dca14(System.Windows.Forms.Control+ControlNativeWindow)->
    014dc888(PNL.ConfigurationTool.UI.WinForms.PrimeTreeView)->
    014dcbdc(System.Windows.Forms.TreeNodeMouseClickEventHandler)->
    014dc594(PNL.ConfigurationTool.Modules.WorkbookTree.WorkbookTreeView)->
    014b24e0(PNL.ConfigurationTool.PnlConfigView+PnlConfigUserNotificationService)->
    014b2504(PNL.ConfigurationTool.UI.WinForms.Util.InternalMessageBoxUserNotificationService)->
    0143b31c(PNL.ConfigurationTool.PnlConfigView)
    DOMAIN(001537B0):HANDLE(WeakSh):a01204:Root:0143bb68(System.Windows.Forms.Control+ControlNativeWindow)->
    0143ba98(System.Windows.Forms.Button)->
    0144126c(System.ComponentModel.EventHandlerList)->
    014e0cdc(System.ComponentModel.EventHandlerList+ListEntry)->
    014e0ca8(System.ComponentModel.EventHandlerList+ListEntry)->
    014c35e0(System.ComponentModel.EventHandlerList+ListEntry)->
    014c35cc(System.ComponentModel.EventHandlerList+ListEntry)->
    0144129c(System.ComponentModel.EventHandlerList+ListEntry)->
    0144127c(System.EventHandler)->
    0143b31c(PNL.ConfigurationTool.PnlConfigView)
    DOMAIN(001537B0):HANDLE(WeakSh):a01210:Root:0143bcc4(System.Windows.Forms.Control+ControlNativeWindow)->
    0143bbf4(System.Windows.Forms.Button)->
    014412e8(System.ComponentModel.EventHandlerList)->
    014e0c74(System.ComponentModel.EventHandlerList+ListEntry)->
    014e0c40(System.ComponentModel.EventHandlerList+ListEntry)->
    014c3520(System.ComponentModel.EventHandlerList+ListEntry)->
    014c3468(System.ComponentModel.EventHandlerList+ListEntry)->
    01441318(System.ComponentModel.EventHandlerList+ListEntry)->
    014412f8(System.EventHandler)->
    0143b31c(PNL.ConfigurationTool.PnlConfigView)
    DOMAIN(001537B0):HANDLE(WeakSh):a01214:Root:0143bee8(System.Windows.Forms.Control+ControlNativeWindow)->
    0143bd50(System.Windows.Forms.StatusStrip)->
    0143c1f4(System.Windows.Forms.ToolStripItemCollection)->
    0143c20c(System.Collections.ArrayList)->
    0143c224(System.Object[])->
    0143c964(System.Windows.Forms.ToolStripStatusLabel)->
    0144132c(System.ComponentModel.EventHandlerList)->
    0144137c(System.ComponentModel.EventHandlerList+ListEntry)->
    0144135c(System.EventHandler)->
    0143b31c(PNL.ConfigurationTool.PnlConfigView)
    DOMAIN(001537B0):HANDLE(WeakSh):a0123c:Root:0143b614(System.Windows.Forms.Control+ControlNativeWindow)->
    0143b31c(PNL.ConfigurationTool.PnlConfigView)
    DOMAIN(001537B0):HANDLE(Pinned):a013e8:Root:02394dc8(System.Object[])->
    013c1294(System.Collections.Generic.Dictionary`2[[System.Object, mscorlib],[System.Collections.Generic.List`1[[Microsoft.Win32.SystemEvents+SystemEventInvokeInfo, System]], mscorlib]])->
    013c1498(System.Collections.Generic.Dictionary`2+Entry[[System.Object, mscorlib],[System.Collections.Generic.List`1[[Microsoft.Win32.SystemEvents+SystemEventInvokeInfo, System]], mscorlib]][])->
    013c1458(System.Collections.Generic.List`1[[Microsoft.Win32.SystemEvents+SystemEventInvokeInfo, System]])->
    013f35b8(System.Object[])->
    014f1fd4(Microsoft.Win32.SystemEvents+SystemEventInvokeInfo)->
    014f1fb4(Microsoft.Win32.UserPreferenceChangedEventHandler)->
    014b20d0(System.Windows.Forms.ProgressBar)->
    014b1f7c(PNL.ConfigurationTool.UI.WinForms.LoadWaitControl)->
    0143b31c(PNL.ConfigurationTool.PnlConfigView)
    DOMAIN(001537B0):HANDLE(WeakSh):a01710:Root:014b2000(System.Windows.Forms.Control+ControlNativeWindow)->
    014b1f7c(PNL.ConfigurationTool.UI.WinForms.LoadWaitControl)
    DOMAIN(001537B0):HANDLE(WeakSh):a01714:Root:014b22f0(System.Windows.Forms.Control+ControlNativeWindow)->
    014b2260(System.Windows.Forms.Label)->
    014b1f7c(PNL.ConfigurationTool.UI.WinForms.LoadWaitControl)
    DOMAIN(001537B0):HANDLE(WeakSh):a0179c:Root:01441118(System.Windows.Forms.Control+ControlNativeWindow)->
    01441004(PNL.ConfigurationTool.UI.WinForms.PrimeComboBox)->
    0144f244(System.Windows.Forms.ComboBox+ObjectCollection)->
    014c0308(System.Collections.ArrayList)->
    014c0928(System.Object[])->
    014b784c(PNL.ConfigurationTool.Modules.WorkbookTree.WorkbookTreeModule)->
    014b3bb4(Prism.Lite.WinForms.Regions.RegionManager)->
    014b3bc4(Prism.Lite.WinForms.Regions.RegionManager+RegionsDictionary)->
    014b3c90(System.Collections.Generic.Dictionary`2+Entry[[System.String, mscorlib],[Prism.Lite.Regions.IRegion, Prism.Lite]][])->
    014b3c2c(Prism.Lite.WinForms.Regions.SingleActiveRegion)->
    014b3d04(System.EventHandler)->
    014b3cec(System.Object[])->
    014b3ccc(System.EventHandler)->
    0143b31c(PNL.ConfigurationTool.PnlConfigView)
    DOMAIN(001537B0):HANDLE(WeakSh):a017d4:Root:014b2000(System.Windows.Forms.Control+ControlNativeWindow)->
    014b1f7c(PNL.ConfigurationTool.UI.WinForms.LoadWaitControl)
    DOMAIN(001537B0):HANDLE(WeakSh):a017e0:Root:0143b31c(PNL.ConfigurationTool.PnlConfigView)->
    014b1f7c(PNL.ConfigurationTool.UI.WinForms.LoadWaitControl)
    DOMAIN(001537B0):HANDLE(WeakSh):a017e4:Root:0143b31c(PNL.ConfigurationTool.PnlConfigView)->
    014b1f7c(PNL.ConfigurationTool.UI.WinForms.LoadWaitControl)
    DOMAIN(001537B0):HANDLE(WeakSh):a017e8:Root:0143b31c(PNL.ConfigurationTool.PnlConfigView)->
    014b1f7c(PNL.ConfigurationTool.UI.WinForms.LoadWaitControl)
    DOMAIN(001537B0):HANDLE(WeakLn):a021c4:Root:014c0a78(System.Windows.Forms.NativeMethods+WndProc)->
    0143b614(System.Windows.Forms.Control+ControlNativeWindow)
    DOMAIN(001537B0):HANDLE(WeakLn):a023b4:Root:014f1e90(System.Windows.Forms.NativeMethods+WndProc)->
    014b2000(System.Windows.Forms.Control+ControlNativeWindow)
    Monday, April 20, 2009 3:15 PM

Answers

  • There's a ProgressBar on a LoadWaitControl on a PnlConfigView in your trace.  It isn't supposed to be there?  Be sure to call the Dispose() method on the LoadWaitControl instances that you remove from the panel.  Just removing it from the panel's Control collection is not enough.
    Hans Passant.
    • Marked as answer by doughboy Tuesday, April 21, 2009 1:22 PM
    Monday, April 20, 2009 8:59 PM
    Moderator

All replies

  • Hello,
    Unfortunatelly there is not much more documentation about SOS commands than what you already found.

    In your case the HANDLE(Pinned) is what is keeping your object alive. There is a GCHandle of type GCHandleType.Pinned which causes it.
    You guessed correctly that HANDLE(WeakSh) and HANDLE(WeakLn) are short and long weak GC Handles (GCHandleType.Weak and GCHandleType.WeakTrackResurrection).

    -Karel
    • Proposed as answer by wmlloyd Wednesday, March 13, 2013 10:22 PM
    Monday, April 20, 2009 7:16 PM
    Moderator
  • There's a ProgressBar on a LoadWaitControl on a PnlConfigView in your trace.  It isn't supposed to be there?  Be sure to call the Dispose() method on the LoadWaitControl instances that you remove from the panel.  Just removing it from the panel's Control collection is not enough.
    Hans Passant.
    • Marked as answer by doughboy Tuesday, April 21, 2009 1:22 PM
    Monday, April 20, 2009 8:59 PM
    Moderator
  • Thanks - I did have to call Dispose on LoadWaitControl.  First of all, I had it declared "private static readonly" in the service it was being used.  I made it an instance member as well as calling Dispose on it later.  It seems that there is a private field in Control called "reflectParent" which doesn't get reset until Dispose is called so it'd hang onto the parent (PnlConfigView in my case).
    Tuesday, April 21, 2009 1:26 PM