On Thu, Oct 6, 2011 at 11:41 AM, Ondřej Žára <[email protected]> wrote:

>
>> The Handle you pass in is not stored.  In fact, looking at the source for
>> SetInternalField, the handle you pass in is dereferenced into the raw
>> Object* and that is stored instead.
>>
>> So doing:
>>
>> A->SetInternalField(0, v8::Persistent<v8::Object>::New(B));
>>
>> is actually leaking a persistent handle to B, since SetInternalField is
>> not holding onto the handle at all and there is no way to get that specific
>> handle back.
>>
>> Another clue about this is that GetInternalField returns a Local, so it's
>> actually generating a new handle every time you look up the value, rather
>> than returning exactly the Handle you originally passed in.
>>
>>
> Aaah! Thanks a lot for the explanation.
>
> Does this also mean that I do not need to empty the internal field, when A
> gets destroyed?
>

I believe that's the case, but I've only had experience storing External
objects wrapping our own raw pointers that we always clear out to ensure
there are no stale references to our own pointers.

matt

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to