Guffa . Java, .
.net , GC.SuppressFinalize. .net ( Java).
Below is a graph of the results - there are no better labels on it ;-). "Debug = true / false" refers to an empty and simple finalizer:
~ConditionalFinalizer()
{
if (DEBUG)
{
if (!resourceClosed)
{
Console.Error.WriteLine("Object not disposed");
}
resourceClosed = true;
}
}
"Suppress = true" refers to a call to GC.SuppressFinalize in the Dipose method.
Summary
For .net, removing an object from the finalizer queue by calling GC.SuppressFinalize is half the cost of leaving the object in the queue.

source
share