Ben thanks for the reply...

For q1) i figured as much...

For q2) Hmm. indeed you are right, although an object may be in scope if it 
is not referenced after the point where GC is initiated then it is eligible 
for garbage collection.
Is there a way to ensure that an object remains valid throughout the 
function scope irrespective if it is referenced or not ?

Furthermore which is the best way to establish parent/child relationships 
between objects (with respect to garbage collection) ?
Please provide a full cycle example if possible.

On Friday, September 27, 2013 10:46:21 PM UTC+3, Ben Noordhuis wrote:
>
> On Fri, Sep 27, 2013 at 7:40 PM, ioannis <ioan...@gmail.com <javascript:>> 
> wrote: 
> > So i'm going to piggyback this post for some additional questions... 
> > 
> > 1) Is it safe to call v8::V8::IdleNotification() within a WeakCallback() 
> to 
> > scavenge additional objects that have been set as weak in WeakCallback() 
> ? 
> > I guess not.. i get a crash. 
>
> Your WeakCallback is invoked when V8 is in the middle* of a GC cycle 
> so no, it's not safe to call v8::V8::IdleNotification(). 
>
> * A post-processing step, actually. 
>
> > 2) Also, lets say within a function scope if an object is declared local 
> but 
> > it is set as Weak i'm experiencing a behavior that the object becomes 
> > garbage collected although it is still in scope... ie 
> > 
> > function foo() { 
> >   var obj; //declared as weak on instantiation 
> >   for (...) { 
> >     var child_obj; //child object of obj also declared as weak on 
> > instantiation 
> >     //at some point obj although in scope becomes garbage collected 
> >   } 
> > } 
> > 
> > So is this an expected behavior or i'm i experiencing a bug ? 
> > Thanks. 
>
> If the reference is not actually used, then yes, it's eligible for 
> garbage collection. 
>

-- 
-- 
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/groups/opt_out.

Reply via email to