On Wed, Jun 14, 2017 at 10:52 PM, Ian Bull <[email protected]> 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