Where’s your leak at? [Using WinDbg, SOS, and GCRoot to diagnose a .NET memory leak]


This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of dlaa.me.

See you there!

Comments (16)
  1. gOODiDEA.NET says:

    .NET NP .NET Profiler – a tool is designed to assist in troubleshooting issues such as slow performance

  2. gOODiDEA says:

    .NETNP.NETProfiler–atoolisdesignedtoassistintroubleshootingissuessuchasslowperf…

  3. Thank you for submitting this cool story – Trackback from DotNetShoutout

  4. It’s been a while since the last post was online. We have been very busy in working on one of the very

  5. Sunil says:

    One thing i have observed in this application is that when we do a refresh using the F5 .the memory is  not releasing rather i will add some more  MB .Is this is releasing the memory correctly i doubt

  6. David Anson says:

    Sunil,

    It's possible there's some kind of a leak in the version of Silverlight you're using. But because I was mainly concerned with helping people understand how to detect (and fix) leaks in their *own* controls, I didn't pay much attention to other things that were going on at the same time. 🙂

  7. Sunil says:

    Ok i understood your intention about this  post .

    But i seriously doubt that the memory management in silverlight version 3 and 4 is not working properly.if you could post some thing that really reduce the leak at least to some 90 %  as this would provide a breather/relief not only for the memory but also the developers.:)

  8. Sergio says:

    I see that my MapTipDialog is leaking but I can't understand the dump. Could you tell me who is keeping my object?

    DOMAIN(0378BE38):HANDLE(Pinned):34f12f8:Root:  05664260(System.Object[])->

     046789d0(System.Collections.Generic.Dictionary`2[[System.IntPtr, mscorlib],[System.Object, mscorlib]])->

     058b7000(System.Collections.Generic.Dictionary`2+Entry[[System.IntPtr, mscorlib],[System.Object, mscorlib]][])->

     0f469a9c(System.Windows.Controls.ControlTemplate)->

     0f46995c(System.Windows.ResourceDictionary)->

     0f469b50(MS.Internal.ResourceDictionaryCollection)->

     0f469bb4(System.Windows.ResourceDictionary)->

     0f46a1bc(System.Windows.Controls.StackPanel)->

     0f46f8ac(System.Windows.Controls.ContentPresenter)->

     0f46f920(System.Windows.Controls.Border)->

     0f46f134(System.Windows.Controls.Grid)->

     0f46f230(System.Windows.Controls.Border)->

     0f46e9f8(System.Windows.Controls.Canvas)->

     0f469360(View.Dialogs.ToolTips.MapTipDialog)

  9. David Anson says:

    Sergio,

    Not offhand, no. 🙁 I'd start by looking at those top three instances to try to figure out what collections are involved and why the control is in them. It's also possible this is due to a platform bug – in which case it might be fixed by a future release of Silverlight.

  10. Sergio says:

    Now I'm starting to guess that it's a bug too because I've removed all content from my control and all interactions but it's still kept by ControlTemplate.

    DOMAIN(0342BE38):HANDLE(Pinned):37012f8:Root:  05664260(System.Object[])->

     046789d0(System.Collections.Generic.Dictionary`2[[System.IntPtr, mscorlib],[System.Object, mscorlib]])->

     057a55e8(System.Collections.Generic.Dictionary`2+Entry[[System.IntPtr, mscorlib],[System.Object, mscorlib]][])->

     0f1d8130(System.Windows.Controls.ControlTemplate)->

     0f1d79d4(View.Dialogs.ToolTips.MapTipDialog)

    Firstly I thought that it is because of binding in my ControlTemplate. I temporary removed it but in vain – the memory is not collected anyway.

  11. David Anson says:

    Sergio,

    The following thread on the Silverlight forums might help – there's a lot going on in there, but it discusses a couple of potential leak scenarios that may be relevant: forums.silverlight.net/…/171739.aspx

    Hope this helps!

  12. Sergio says:

    Thanks for reply!

    Finally I decided to reuse all leaking controls rather than create new instances in order not to spend time for exploring each case of leaking.

  13. David Anson says:

    Sergio,

    That sounds like a great solution!

  14. Marc says:

    What does it mean when !gcroot <address> returns 'Found 0 unique roots (run !GCRoot -all to see all roots)'?  

    When I run GCRoot -all <address> it sits there forever (well, more than 20 minutes, I haven't let it go on forever.)

  15. David Anson says:

    Marc,

    It sounds like the specific object instance you're passing to GCRoot is not actually rooted. In other words, it's garbage and will be removed during the next collection.

    PS – Running GCRoot on a large application with many objects in memory can sometimes take a long while to complete; I suspect that's the source of the delay you're seeing with "-all".

Comments are closed.

Skip to main content