The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Memory Leaks? Leaking IDisposable objects? MemProfiler is your friend.

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mark Levison

Posts: 877
Nickname: mlevison
Registered: Jan, 2003

Mark Levison an agile software developer who writes Notes from a tool user.
Memory Leaks? Leaking IDisposable objects? MemProfiler is your friend. Posted: Oct 1, 2004 10:01 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Mark Levison.
Original Post: Memory Leaks? Leaking IDisposable objects? MemProfiler is your friend.
Feed Title: Mark Levison
Feed URL: /WebLog/error.aspx?aspxerrorpath=/WebLog/mlevison/Rss.aspx
Feed Description: Musings on No Touch Deployment, .NET development and photography
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Mark Levison
Latest Posts From Mark Levison

Advertisement

For the past few days I've been tracking down some nasty memory leaks in our product and SciTech's MemProfiler has saved my bacon. It turns out that we had a number of short lived objects (foo) subscribing to events on long lived objects (bar) and never releasing those events. As a result the objects the foo objects lasted forever.

The documentation is a bit weak so for the benefit of first time users, here is how I use it:

  1. Start your application and do "some work"
  2. Take a snapshot
  3. Do some more work and take another snapshot
  4. Now the fun begins: Go to the classes tab (left most)
  5. Sort by the delta either on number of instances or bytes and look for unexpected growth
  6. Double Click on a suspicious class (MemProfiler switches to the class details tab)
  7. Double Click on an interesting instance (MemProfiler switches to the instance tab)
  8. Laid out in front of you are:
      list of Objects that reference you
      paths back to the root for each instance
      the allocation stack for this object
  9. Find the reference to your object that is keeping it alive and fix the code
  10. Rerun the process to verify
  11. Jump for joy that this problem was so damn simple to fix
Now I just have to figure out how to write unit tests that will detect these leaks. Nothing's perfect and I have few feature requests for SciTech:
  1. Given an instance I would like to be able to display a graph of what it references and what references it. Often the references we've stumbled across are loops and so shouldn't stop the objects from being garbage collected.
  2. In the Classes tab, I would like a field that gives the total number of bytes for this object and all its dependants. MemProfiler tells me our application has allocated a large number of int32's. By itself that's not very useful - knowing what data structures they belong to is.
  3. Work NUnit/MbUnit without crashing - the current version has some problems with reflection. Andreas has promised the next version will fix this.
  4. More information for 'undisposed instances' (IDisposeable objects that weren't disposed before they went out of scope). Specifically where these objects allocated. Otherwise its like tracking down a needle in haystack. We allocate over 200 Bitmaps - most of which we handle well. It was a pain to find the few that SciTech said were leaking.
  5. Better documentation

Best part it only costs $100 US.


This Blog Hosted On: http://www.DotNetJunkies.com/

Read: Memory Leaks? Leaking IDisposable objects? MemProfiler is your friend.

Topic: Change the size of the search box in Firefox 1.0PR Previous Topic   Next Topic Topic: Password Scrambler

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use