Why my dataset doesn't release memory!!
Hi all,
I see there are a lot of question about it ...but no way to solve this problem....
In code like :
using (Dataset ds = new dataset())
{
.........some ds stuff................
}
even if
ds.dispose()
or
ds=null
or
GC.Collect()
the memory is not released.
Many thanks
Re: Why my dataset doesn't release memory!!
This should help explain how a garbage collector works:
http://en.wikipedia.org/wiki/Garbage...ter_science%29
Re: Why my dataset doesn't release memory!!
Quote:
I see there are a lot of question about it ...
... and there's a lot of answers about it, like limiting your SQL query or use a DataReader instead or just leaving the GC alone because it's nothing to worry about.
If you REALLY want to force a GC cycle do this outside the using block (after making sure nothing holds a reference to your data set i.e. don't set it as a source on a DataGrid, don't hold it in a member variable) :
Code:
GC.GetTotalMemory(true);
but you shouldn't.
If you need deterministic cleanup of memory use C++.
Darwen.