DataSet/datatable Dispose

G

Guest

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
 
J

Jon Skeet [C# MVP]

Niranjan said:
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.
 
G

Guest

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
 
S

Sean Hederman

Niranjan said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top