2

I'm debugging a memory leak. I cannot reproduce it, but when the program runs in specific circumstances I get a steady leak at about 60MB/hr. After several days, I take a dump when the heap is ~2GB and attach WinDbg.

!heapdump –stat
Shows there are 1.2 GB worth of Hashtables. This is about 55% of the heap.

!dumpheap -Type System.Collections.Hashtable+KeyCollection
Gives address of the 153,080 Hashtable instances.

!gcroot of a few of these instances indicate that they are all owned by Threads owned by Me.Logger.

RSP:28f67e840:Root:0000000245edb7d0(Me.Logger)->
0000000245edb9d8(System.Threading.Thread)->
00000002459b9830(System.Runtime.Remoting.Contexts.Context)->
00000002459b9548(System.AppDomain)->
0000000245a1fed0(System.ResolveEventHandler)->
00000002259697a0(System.Web.Compilation.BuildManager)->
0000000245a20120(System.Web.Compilation.MemoryBuildResultCache)->
00000002459c2a48(System.Web.Caching.CacheMultiple)->
00000002459c2a70(System.Object[])->
00000002459c7e08(System.Web.Caching.CacheSingle)->
00000002459c9008(System.Web.Caching.CacheUsage)->
00000002459c9030(System.Object[])->
00000002459c9138(System.Web.Caching.UsageBucket)->
00000001b996fba8(System.Web.Caching.UsagePage[])->
00000001ae054388(System.Web.Caching.UsageEntry[])->
0000000251576590(System.Web.Caching.CacheEntry)->
00000002515761a0(System.Web.Mobile.MobileCapabilities)->
00000002515742c8(System.Collections.Hashtable)->
0000000251576548(System.Collections.Hashtable+KeyCollection)

I don't know how to interpret this output. It seems that System.Web.Compilation.BuildManager just has a massive cache.

BuildManager, MobileCapabilities, ResolveEventHandler - I don't use any of this in my codebase.

I am new to WinDbg. How do I debug this further?

How could I see what's in the Hashtables? (SoS v2.0.50727 so no !DumpCollection). How could I see what BuildManager has built?

1 Answer 1

0

Have you tried the SOSEX extension? http://www.stevestechspot.com/default.aspx. It has most of the functionality of SOS including !DumpCollection command that you need (although I haven't tested if it works with V2 of the CLR) and maybe some other useful things..

Also maybe this blog can help you, she has some pretty good information on managed memory leak debugging:

http://blogs.msdn.com/b/tess/archive/2008/04/03/net-debugging-demos-lab-7-memory-leak-review.aspx?PageIndex=1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.