DataSet and Dispose

  • Thread starter Thread starter Hans Kesting
  • Start date Start date
H

Hans Kesting

Hi,

What are the performance benefits of calling Dispose on a DataSet?

We have a (web) application that we tried to run on a shared server.
It crashed due to memory constraints.
The helpdesk of the hoster said "you need to call Dispose on every
object". Now I know that not every object implements this method,
but DataSet does (and we use it a lot).

I understand that you need to call Dispose when you use unmanaged
resources (like handles to the filesystem or database), and we do.
However when I read the documentation for DataSet it seems to me
that Dispose only has effect for remote datasets. DataSet does not
implement Dispose itself, but inherits it from MashalByValueComponent.

It shouldn't hurt to call Dispose at the appropriate moment, but will
it help in keeping the memory-use down?

Hans Kesting
 
Hans,

Calling dispose should do nothing, you better can check in my opinion if you
do not have some open reference somewhere to your dataset. That is easily
done in the situation of a dataset. And the dataset is only freeed by the GC
when there are no references anymore to it. Setting itself to nothing helps
not much.

Cor
 
Cor said:
Hans,

Calling dispose should do nothing,

I thought so.
you better can check in my opinion
if you do not have some open reference somewhere to your dataset.
That is easily done in the situation of a dataset.

If we have done our job right, this shouldn't happen (in case of a
WEB application, this should only happen when you store it in Session
or Cache or something like that)
And the dataset is
only freeed by the GC when there are no references anymore to it.
Setting itself to nothing helps not much.

I know.


Thanks.
Hans Kesting
 
Back
Top