How to make sure GC allocated resources stay around when used in C functions?

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 12 12:13:26 PDT 2014


AFAIK, addRoot is for memory allocated in GC heap, and addRange 
is for other types of memory, so you can't add non-gc memory as 
root (just a guess, see docs). I would allocate whole Args in GC 
heap and add is as root, yes, it would prevent collection until 
the root is removed. A better way would be to store Args in a 
linked list in the widget, this way it will be fully managed, and 
Args will live as long as the widget class instance references 
them without additional tinkering with GC.


More information about the Digitalmars-d-learn mailing list