ts******@gmail.com wrote:
I remember reading a few years back about destructors not being
guarenteed to be run. Doing a search all I can find is a reference to
some bugs with finalizers and appdomains in 1.0 and 1.1. Are
destructors guarenteed to be called in every case? Are there any
pathological cases?
Finalizers are not guaranteed to run, and it's not a bug.
There is no destructors in .NET. There are no reference counters.
Nothing happens when the last reference to an object goes out of scope.
The object will just stay in memory until the garbage collector collects it.
When the garbage collector finds an object that is not used and it has a
finalizer, it will be placed in the finalizing queue, where the
finalizer eventually will be called by a background thread.
If an object has not been collected when the application ends, or if
it's still in the finalizing queue, the finalizer will never run.