IDisposable, does it really matter

Posted by adrianm on Stack Overflow See other posts from Stack Overflow or by adrianm
Published on 2010-03-17T19:39:08Z Indexed on 2010/03/17 19:41 UTC
Read the original article Hit count: 177

Filed under:
|
|

Coming from C/C++ a long time ago I still have a habit of ensuring that all resources are cleaned up correctly. I always ensure Dispose is called on IDisposable classes and implement Dispose patterns in my classes containing disposable objects.

However, in my environment I'm more or less the only one doing this. Others just don't understand what I'm doing and think my code is more difficult to understand.

They just create database connections, open streams etc without calling Close or Dispose. Sometimes they set a local or member variable to "Nothing" at the end of a method (guess their background).

My problem is that their code works just as well as mine. Code that over time creates thousands of database connection objects just works.

So, ignoring any arguments about code correctness, following guidelines etc, does IDiposable really matter?

Has anyone actually ran out of resources from not Disposing objects?

© Stack Overflow or respective owner

Related posts about idisposable

Related posts about .NET