Dispose Objects

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

Hi Guys,
Suppose we are using a DataSet within a windows application. Should we
dispose it when the form closes or leave it for Garbage Collector. DataSet
might be hugh.

Please advice.
Thanks, Richard
 
Here is a quote from the .NET Developer's Quide
http://msdn2.microsoft.com/en-us/library/0s71x931(en-US,VS.80).aspx

For the majority of the objects that your application creates, you can rely
on the .NET Framework's garbage collector to implicitly perform all the
necessary memory management tasks. However, when you create objects that
encapsulate unmanaged resources, you MUST EXPLICITLY release the unmanaged
resources when you are finished using them in your application. The most
common type of unmanaged resource is an object that wraps an operating system
resource, such as a file, window, or network connection. Although the garbage
collector is able to track the lifetime of an object that encapsulates an
unmanaged resource, it does not have specific knowledge about how to clean up
the resource.

End Quote
 
Back
Top