Undisposed objects

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
Posts: 1
Joined: Thu Sep 25, 2008 8:54 am

Undisposed objects

Post by Ace » Thu Sep 25, 2008 8:59 am

How does .NET Memory Profiler determine whether an object has been disposed? (I'm running v2.6)

The tool is reporting many undisposed instances of SortedList<>.Enumerator. The enumeration is done through Linq, but even if I re-write the code to use a foreach (or a using+while loop, which is the same thing), the Enumerator objects still show up as undisposed.

Any ideas on why that might be happening?

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Fri Sep 26, 2008 6:39 am

SortedtList<>Enumerator is a value type. Value types that implement IDisposable are not treated as disposable classes in the current version and Dispose method calls are not tracked.

However, in v2.6, a boxed value type implementing IDisposable is classified as a disposable class, but Dispose method calls are still not tracked. This causes a boxed instance to be counted as undisposed when it's GCed. This is a bug that is easily fixed, but we have not built a new version of v2.6 for nearly two years, so I'm not sure how long it will take. I will get back to you when I have some more information.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: No registered users and 37 guests