Destructor/Finalizer Guarantees

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 12 06:36:18 PST 2014


With GC you usually have two destructors: one for managed 
resources and one for unmanaged resources. Destructor for managed 
resources should be run on live objects as soon as you don't need 
the resource, it calls unmanaged destructor too. Unmanaged 
destructor (finalizer) is called by GC during garbage collection 
and frees unmanaged resources (not managed by GC). Since they are 
not managed by GC, you decide, how they are disposed. Though 
calling finalizer during collection is a last resort for resource 
management, unmanaged destructor should be normally called from 
managed destructor.


More information about the Digitalmars-d-learn mailing list