Thanks Ben,

I tried setting it weak, and noticed that it still was considered "not near 
death". However, after a while, this did change. So this is consistent with 
your assertion that it's not instantaneous.

I was going to expose this API in my Java bindings, but maybe I'll skip if 
for now. Do you know what this API would be useful for, or have you seen 
real world examples of people using it?

Cheers,
Ian

On Thursday, 15 June 2017 02:08:07 UTC-7, Ben Noordhuis wrote:
>
> On Wed, Jun 14, 2017 at 10:52 PM, Ian Bull <[email protected] <javascript:>> 
> wrote: 
> > The documentation of IsNearDeath says: 
> > 
> > "Checks if the handle holds the only reference to an object." 
> > 
> > But I'm not sure this is correct. 
> > 
> > If I create a new Object, and place it in a persistent container, and 
> the 
> > immediately call "isNearDeath", it returns false: 
> > 
> >   Local<Object> obj = Object::New(isolate); 
> > 
> >   Persistent<Object>* container = new Persistent<Object>; 
> > 
> >   container->Reset(reinterpret_cast<V8Runtime*>(v8RuntimePtr)->isolate, 
> > obj); 
> > 
> >   container->IsNearDeath(); // returns false 
> > 
> > 
> > But in this case, this is the only handle to the object, no? 
>
> I think the meaning of IsNearDeath() may have shifted over time.  It 
> used to mean "about to be reclaimed by the garbage collector" but 
> these days it can also mean "only reachable through weak handles". 
> The second one doesn't apply to your example: it's a strong reference, 
> not a weak one. 
>
> Also, it's not instantaneous, I believe the state is updated after 
> major garbage collection cycles. 
>

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to