I was just reading this article,
“Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework”, by Jeffrey Richter, and I couldn't think of any real life sample for using ReRegisterForFinalize
or SuppressFinalize
.
Could anyone provide me with some examples?
A handful of places it gets used in the .NET framework, always a good place to look. Basic patterns are:
The implementation of IDisposable
often requires SuppressFinalize
: look here or here for the code.
I don't have a good example on ReRegisterForFinalize
now.
You need ReRegisterForFinalize
when resurrecting an instance. Resurrection (mentioned in the linked article) is the action of re-rooting an object from its destructor (finalizer).
That only moves the question to "when would you resurrect an object". In my answer to this question I speculated that a connectionpool or similar construct might use it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With