Jaa


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

  • Anonymous
    March 11, 2009
    PingBack from http://blogs.msdn.com/delay/archive/2009/03/11/where-s-your-leak-at-using-windbg-sos-and-gcroot-to-diagnose-a-net-memory-leak.aspx

  • Anonymous
    March 12, 2009
    .NET NP .NET Profiler – a tool is designed to assist in troubleshooting issues such as slow performance

  • Anonymous
    March 12, 2009
    .NETNP.NETProfiler–atoolisdesignedtoassistintroubleshootingissuessuchasslowperf...

  • Anonymous
    March 13, 2009
    Thank you for submitting this cool story - Trackback from DotNetShoutout

  • Anonymous
    March 21, 2009
    It's been a while since the last post was online. We have been very busy in working on one of the very

  • Anonymous
    July 27, 2010
    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

  • Anonymous
    July 28, 2010
    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. :)

  • Anonymous
    July 28, 2010
    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.:)

  • Anonymous
    August 02, 2010
    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.Dictionary2[[System.IntPtr, mscorlib],[System.Object, mscorlib]])->  058b7000(System.Collections.Generic.Dictionary2+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)

  • Anonymous
    August 02, 2010
    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.

  • Anonymous
    August 02, 2010
    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.Dictionary2[[System.IntPtr, mscorlib],[System.Object, mscorlib]])->  057a55e8(System.Collections.Generic.Dictionary2+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.

  • Anonymous
    August 03, 2010
    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!

  • Anonymous
    August 06, 2010
    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.

  • Anonymous
    August 07, 2010
    Sergio, That sounds like a great solution!

  • Anonymous
    September 22, 2011
    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.)

  • Anonymous
    September 22, 2011
    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".