[For future reference - it would be better to give a subject line which
actually describes your problem. You may also have alienated others who
have a perfectly good answer but aren't MVPs.]
Vai2000 <no****@microsoft.com> wrote:
Hi All, To my correct understanding Garbage Collection works based on
Generation algorithm...(high level).
I have an application which does some heavy operations usually File I/O's. I
want to force garbage collection on this class. I still want the GC to
release all resources before finalizing etc...but I want GC to kick in ASAP,
rather waiting to execute its algo to detect that this class needs cleaning
up and finally come to its rescue...
This is what I have implemented. Please advice
class Foo:IDisposable
{
public void Dispose()
{
GC.Collect();
}
}
That looks like a very bad idea to me. Why do you think it's a good
idea to force garbage collection? Much better would be to call Dispose
on all the appropriate streams explicitly. That will release the
unmanaged resources but not force a potentially expensive garbage
collection.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too