On Tue, May 8, 2018 at 1:19 AM, ibon <ibon.tolos...@gmail.com> wrote: > 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
Yes, the effect of MarkActive() only persists until the next garbage collection. I wonder though, why don't you call ClearWeak()? That keeps the object alive until MakeWeak() is called again. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.