Can I call GC.addRoot from constructor and trigger collection with destroy()?

Robert M. Münch robert.muench at saphirion.com
Sun Jul 1 21:59:56 UTC 2018


I'm creating a bunch of objects and need to use these object pointers 
with C code. Hence I need to protect them from being GC with GC.addRoot.

Can this call be made out of a constructor? So that I can protect the 
objects as earyl as possible?

Could I then unprotect the memory inside the destructor, which I would 
call explicitly via destroy(...)? Or would a call to destroy be 
sufficient to tell the GC, now you can collect the memory?

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list