Don't expect class destructors to be called at all by the GC

Mike Franklin slavo5150 at yahoo.com
Fri Dec 22 00:09:31 UTC 2017


On Thursday, 21 December 2017 at 19:43:16 UTC, Steven 
Schveighoffer wrote:

> The gist is, you cannot expect that destructors will be run in 
> a timely manner, or at all.
>
> They may be called, and most of the time they are. But the 
> language nor the current implementation makes a guarantee that 
> they will be called.

I understand that we can't deterministically predict when a 
destructor will be called, but if we can't deterministically 
predict if a destructor will be called, that seems asinine.

What condition(s) would cause a destructor for an object that is 
managed by the GC to potentially not be called?

Thanks,
Mike



More information about the Digitalmars-d-learn mailing list