Get rid of DataTable

  • Thread starter Thread starter Jordan S.
  • Start date Start date
J

Jordan S.

How can get rid of a DataTable instance?

Set it to null + call Dispose on it? Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?

Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and the garbage
collector is free to have it's way with it.

Thanks.
 
How can get rid of a DataTable instance?

Set it to null + call Dispose on it?  Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?

Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and the garbage
collector is free to have it's way with it.

Thanks.

Hi,

You can call Dispose if it implement it, and you can set it to null.
this will free the memory IF (and that's a capital if) it's not
referenced somewhere else,like for example in a DataSet
 
Hi,

You can call Dispose if it implement it, and you can set it to null.
this will free the memory IF (and that's a capital if) it's not
referenced somewhere else,like for example in a DataSet

Then you can call

System.GC.Collect(); to force garbage collection.
 
Then you can call

System.GC.Collect();  to force garbage collection.- Hide quoted text -

- Show quoted text -

Unless you have a REAL justification I would leave the GC work his
magic alone
 
Jordan said:
How can get rid of a DataTable instance?

Set it to null + call Dispose on it? Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?

Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and the garbage
collector is free to have it's way with it.

Thanks.

General rule is to always call Dispose on objects that implement the
IDisposable pattern, when you're done with the object.

DataTable implements IDisposable since it inherits from
MarshalByRefComponent, and doesn't even override Dispose, so basically
the only code involved in IDisposable for a DataTable is what's in
MarshalByRefComponent.

Unless you have specific reasons for *not* calling Dispose, don't
second-guess what the code does and just call it.
 
Unless you have a REAL justification I would leave the GC work his
magic alone- Hide quoted text -

- Show quoted text -

I would say that is correct. Unless you have a cheapie company that
has low end machines and your data tables are large wait for the
garbage collector to do its thing automatically. If you jsut really
want to for=ce everything to be scrubbed the option is there. I would
think by .NET 3.5 they would have all of the kinks worked out of
manual garbage collection but I haven't had to use it in a long time
since we have decent machines here and I have learned to slim down my
footprint.
 
Marc said:
I would say that is correct. Unless you have a cheapie company that
has low end machines and your data tables are large wait for the

I don't think you should need to manually call the garbage collector on
any machine at all.

The garbage collector registers with Windows for low-memory conditions,
and will, when needed, start to run more often if some other application
needs the memory. In other words, GC will run as often as required.
 
I don't think you should need to manually call the garbage collector on
any machine at all.

The garbage collector registers with Windows for low-memory conditions,
and will, when needed, start to run more often if some other application
needs the memory. In other words, GC will run as often as required.


--
Lasse Vågsæther Karlsen
mailto:[email protected]://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3- Hide quoted text -

- Show quoted text -

See, when I was working in 1.1 that wasn't always true. The system did
a lot of swapping when it had dead objects it could clean up which is
why I did it back then. I would hope things are different now but I
haven't been forced to use it. I guess my thoughts are based on old
technology at this point.
 
Back
Top