Is it possible to avoid call to destructor for structs?

Haridas haridas at systemc.net
Mon Sep 25 04:22:39 UTC 2017


> In your case, the postblit of Bar is still going to run and add 
> a ref to it's count when you place it in Foo, right? That means 
> that if you don't destroy it, it will leak memory or resources.
>

Actually no. Since when Foo (class that instantiates Bar) gets 
GCed, that is the point that I need to destroy the whole 
infrastructure around Bar, including its recounted GC. So I am Ok 
if destructor of Bar does not get called this one time since I am 
just going to delete the whole block of memory that I have 
allocated for placing the refcounted instances of Bar.


More information about the Digitalmars-d-learn mailing list