DataSet/datatable Dispose

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
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
 
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.
 
Back
Top