IDisposable – The oft misunderstood and misused interface

During my time following Stack Overflow, one of the most common misconceptions I’ve run across has been confusion in the understanding of IDisposable.

For example, the author of this post confused IDisposable with a way to explicitly free memory.  This question is related to the way using works, how and when to use the using statement.  Here a poster was asking about trying to force the GC to collect earlier…

There are many blog posts and articles online which do an excellent introduction to IDisposable, but most focus on just one aspect of this interface.  In my view, it is too complex of a subject to be tackled in a single article.  To that end, I’m going to break this into a series, each post describing one aspect of using IDisposable in detail.  Hopefully, this will be a way to clear up many of the misconceptions of explicit resource handling in C# and .NET.

(Edit on July 8th)

Now that I’ve completed these, I thought I’d include links to the full series.  The articles in this series, in order:

IDisposable Part 1 – Releasing Unmanaged Resources

IDisposable Part 2 – Subclass from an IDisposable class

IDisposable Part 3 – Encapsulating an IDisposable class

IDisposable Part 4 – Factored Types

IDisposable Part 5 – Using IDisposable Classes in C#

About Reed
Reed Copsey, Jr. - -


One Response to “IDisposable – The oft misunderstood and misused interface”
  1. superstringcheese says:

    Thank you so much for putting this together. This is exactly the kind of important subject that a developer is expected to know somehow, but for which there is no consolidated, guided resource.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!