TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

Call Dispose on DataSets

I received an interesting answer from Joe Duffy at the MSDN Performance chat about calling dispose on a DataSet. Check out the answer...

A: Yes, anything that implements IDisposable (or which has a class in its base hierarchy that does) should be disposed of when you're done with it. Otherwise, you're potentially hanging on to precious resources that should otherwise have been released earlier. These will normally get cleaned up inside their finalizers, but there's a cost with keeping an object around on the finalizer queue too. DataSet, for example, derives from MarshalByValueComponent... this base type does some work in its Dispose method, so calling it on DataSet is still worthwhile.


Digg!

posted on Wednesday, March 09, 2005 9:15 PM

Feedback

No comments posted yet.