Since there is as of
yet no data access API that is 100% managed (and there will not likely
ever
be) it is important to dispose all objects that implement IDisposable. We
have had problems in the past with memory leaks that were not resolved
until
we started calling Dispose.
The only caution that I offer with Dispose is that once its called, there
is
no going back. Make sure that there are not other objects refrencing the
disposed object as they could cause exceptions if methods or properties
are
called after Dispose is called.
Matt Osborne
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
How do you know if the class is holding unmanaged resources?
You should call Dispose on every instance to relase resources asap.
Plus, you don't know what the future changes might be.
So, call Dispose on anything that implements IDisposable asap.
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com
You really don't need to bother disposing a DataSet (or any other .NET
object for that matter) unless the object is holding on to unmanaged
resources that need to be manually cleaned up when you are done using the
object. This is the whole point of the Garbage Collector.
Hi,
Once a dataset is populated from DataAdapter, I want to release the
memory acquired by dataSet object. So I call oDataSet.Dispose(). But
it doesnot disposes the internal objects like Datatable/dataColumn.
Should I have to call Dispose() method for these internal objects
explicitely? OR DataSet.Dispose() takes care to clear the internal
objects?
Thanx,
Atul