Now i won't deal with the theory.
just a brief look on code.
To force GC to collect the candidate to dispose
GC.collect();
GC.WaitForPendingFinalizers();
This will make GC wait for all of the finalizer of every suspected object to be called
You can override finalizer with short key ~
~thenameoffinalizer()
{
//do something
}
The right thing to write on the so When calling finalizer also call dispose
~Thing()
{
Dispose();
//Do something on finalizer
}
can do try catch, if error register again to finalize with this command
GC.ReRegisterForFinalize(t);
There are also to check the total memory method on GC.
long G =GC.GetTotalMemory(true);
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar