For my embedding needs, sometimes i need to keep a native wrapped object alive.
Normally, I set a Persistent ref where i install a finalisation callback with custom wrapper class is. This gives me fine control of all native wrapped objects at Isolate level, and the GC kicks in as expected.
I have found that to keep an object alive, I can set a Private property on a parent object. E.g a TouchEvent, keeps a private ref to a TouchList. Private properties is an experimental feature, so not sure if this is discouraged though.
This works for this specific case, where a TouchEvent refers just one TouchList.
While implementing other types of objects, like an Image, I need to keep the image javascript wrapper alive until async loading finishes so that I get the chance to notify registered event observers. For this purpose, I use MarkActive, which keeps the object alive, and as expected, it also keeps live the whole object tree where it is contained.
Since there's no equivalent to `unmark active`, I guess MarkActive'd objects survive just one GC cycle ? If necessary, should I call MarkActive again if I still need to keep my object alive ?
Is this the way to go for keeping objects alive ?
Thanks.
- ibon