Now that we are on this, can I ask more questions about GC:

Is calling LowMemoryNotification() expensive?  Should I only do it when I 
absolutely need more memory to continue, or should I do it proactively and 
in small batches?


On Friday, January 22, 2016 at 11:41:08 PM UTC-8, Jane Chen wrote:
>
> Jochen,
>
> My bad.  I only registered a callback for the iterable object returned 
> from sequence(), but not for the iterator returned from 
> [Symbol.iterator]().  v8 did the right thing by freeing the iterable object 
> in this case.  So the bug was in my code.
>
> Thanks for your response.
>
> Jane
>
> On Friday, January 22, 2016 at 12:54:25 AM UTC-8, Jochen Eisinger wrote:
>>
>> would you mind filing a bug for this? Ideally, with a self-contained 
>> repro case!
>>
>> thanks
>> -jochen
>>
>> On Fri, Jan 22, 2016 at 12:23 AM Jane Chen <jxch...@gmail.com> wrote:
>>
>>> Embedding v8 4.6.88.
>>>
>>> Suppose my native function sequence() returns a JavaScript iterable 
>>> wrapping a long sequence of internal objects; function gc() invokes 
>>> v8::Isolate::LowMemoryNotification().  To reduce memory consumption of the 
>>> iterable, gc() needs to be called periodically to release the objects no 
>>> longer referenced by the script.
>>>
>>> The following script is able to iterate through the sequence to the end, 
>>> and when gc() is called, no weak callback is called to the object backing s:
>>>
>>> var i = 0; var s = sequence(); for (doc of s) { i++; if (i%1000 == 0) 
>>> gc(); } i
>>>
>>> ==> 131108
>>>
>>>
>>> However, if no variable s is defined, the execution stops after the 
>>> first gc, because the object returned from sequence() is also collected at 
>>> gc:
>>>
>>> var i = 0; for (doc of sequence()) { i++; if (i%1000 == 0) gc(); } i
>>>
>>> ==>1000
>>>
>>>
>>> This looks like a bug to me.  Can anyone chime in?
>>>
>>> -- 
>>> -- 
>>> v8-users mailing list
>>> v8-u...@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+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
-- 
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.

Reply via email to