Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

DataSet/datatable Dispose

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Niranjan - 30 May 2005 08:21 GMT
when dataset/datatable will be disposed ?

After calling Dispose(), when i access DataSet or DataTable, the object
exists.
Even after calling GC.Colect(), when i access them, the object and data
exists.
Can anyone explain why & how.

When i call dispose on dataset, will it automatically dispose all datatables
that it contains ?

thanks
niranjan
Jon Skeet [C# MVP] - 30 May 2005 08:30 GMT
> when dataset/datatable will be disposed ?
>
> After calling Dispose(), when i access DataSet or DataTable, the object
> exists.
> Even after calling GC.Colect(), when i access them, the object and data
> exists.

The fact that you're able to access them means they can't be garbage
collected.

> Can anyone explain why & how.
>
> When i call dispose on dataset, will it automatically dispose all datatables
> that it contains ?

I don't believe Dispose does anything on a DataSet unless it's
contained in a site, or has a listener subscribed to the Disposed
event. It's basically got a Dispose method because it derives from
MarshalByValueComponent.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Niranjan - 31 May 2005 04:08 GMT
Thanks Jon,

I have huge datasets being used in my application (let say serviced
components & long running batch applications), how will i ensure that the
memory is cleaned esp with DataSets/DataTables.

thanks
niranjan

> > when dataset/datatable will be disposed ?
> >
[quoted text clipped - 15 lines]
> event. It's basically got a Dispose method because it derives from
> MarshalByValueComponent.
Sean Hederman - 31 May 2005 05:35 GMT
> Thanks Jon,
>
> I have huge datasets being used in my application (let say serviced
> components & long running batch applications), how will i ensure that the
> memory is cleaned esp with DataSets/DataTables.

Stop referencing them. If you can access them then they cannot be garbage
collected. Either let the variables holding them go out of scope, or set
them to null.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.