How to use destroy and free.
    Stanislav Blinov 
    stanislav.blinov at gmail.com
       
    Mon Apr 25 12:51:08 UTC 2022
    
    
  
On Monday, 25 April 2022 at 10:13:43 UTC, Alain De Vos wrote:
> Ali, thanks for the answer but i rephrase my question.
> How to destroy,free , for garbage-collection-cycle in the 
> destructor of this code :
>
> // But How to force destroy and free , GC-cycle for heap object 
> i ?
Short answer: use `destroy`. Long answer: don't do that.
https://dlang.org/spec/class.html#destructors
GC is not guaranteed to call destructors, and in fact it may run 
into situations when it can't (i.e. objects pointing to one 
another). Neither does it specify in what order destructors of 
GC-allocated objects are run (when they are run). If you need 
deterministic destruction e.g. for resource management, do not 
use GC.
    
    
More information about the Digitalmars-d-learn
mailing list