I'm curious, what really happens inside .NET
, if exception happened in finalizer method during garbage collection procedure. Did the logic different for heap and LOH? Could anyone provide detailed description?
Nothing much special. The CLR will detect the exception and terminate the program.
Do note that the article linked by @kmatyaszek is grossly outdated. Swallowing exceptions in finalizers and worker threads was a .NET 1.x feature that caused a lot of misery. It is pretty difficult to diagnose the reason a program stops behaving properly when this happens. .NET 2.0 put an end to it, the default policy is to always terminate the program. Technically that can be overridden by a custom CLR host and the <legacyUnhandledExceptionPolicy>
element in the app.exe.config file. Don't use it unless you like misery.
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