Live Chat Icon For mobile
Live Chat Icon

When I add a destructor to a class, why isn’t it hit when my instantiated object goes out of scope

Platform: WinForms| Category: from MFC

Your managed code doesn’t have a destructor, just a finalizer. The difference is a destructor (as in C++) fires immediately when an object goes out of scope, but a finalizer is run when the CLR’s garbage collector (GC) gets to your object. It’s not deterministic when this will occur, but it’s very unlikely to occur right after the object goes out of scope. It will happen at a later time, however.

(from on microsoft.public.dotnet.framework.windowsforms)

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.