Also @Gautham B A we have not figured out a good solution yet - still 
reviewing the best way to actually get around this.

On Monday, May 1, 2017 at 11:20:55 AM UTC-4, Brendan Bates wrote:
>
> Seems relevant enough to me if you like efficient programs
>>
>
> Oh I definitely agree it's important, just that the topic on hand isn't 
> necessarily the performance impact but the memory usage.  In our case, we 
> accept the performance
> impact for the flexibility of the solution.
>
>  It's not an issue when you create the ObjectTemplate once but it does 
>> become an issue when you create the ObjectTemplate afresh every time. 
>
>
> I have a question in response to this then.  How would you handle a 
> dynamic multi-indexed field mapped to a C++ object?  Currently we have a 
> root ObjectTemplate with an
> indexed property handler that knows it is the first of three indices.  The 
> handler when requested will then generate a new ObjectTemplate with an 
> indexed handler that knows it is the
> second of three indices, etc.  So yes, every call to "var test = 
> data[1][2][3]" will generate three object templates as it goes up the 
> chain.  Perhaps this is not possible/best use of v8, as a function call for 
> fetching the object could accomplish this.  However for our system, that is 
> less declarative than just using array notation.  Unfortunately a stock 
> object does not provide a way of setting an indexed property handler (as 
> far as I know).
>
> As an aside to all of this - is this considered a bug?  I feel like if 
> not, the repercussions of this should be documented somewhere such as the 
> NewInstance call in the v8 API.  I would not
> have caught this if we didn't run some stress tests on our system.  I 
> wrote a test that generates tens of MB per second (even when calling 
> LowMemoryNotification) from using this behavior.
>  
> On Monday, May 1, 2017 at 11:08:01 AM UTC-4, Ben Noordhuis wrote:
>>
>> On Mon, May 1, 2017 at 4:25 PM, Brendan Bates <[email protected]> 
>> wrote: 
>> >> I don't see an actual memory leak in the code you posted but creating 
>> >> a new ObjectTemplate for every query isn't very efficient. 
>> > 
>> > Just wanted to reply to this to say, that is an irrelevant point to 
>> this 
>> > discussion.  Even if you are using it sparingly, if you have a 
>> long-running 
>> > script that calls NewInstance(), then 
>> > this would be a problem. 
>>
>> Seems relevant enough to me if you like efficient programs but I take 
>> back my words because there is a memory leak: ObjectTemplate::New() 
>> produces a template that caches instantiations.  The first 
>> instantiation is cached, subsequent instantiations are cloned from 
>> that cached instance. 
>>
>> It's not an issue when you create the ObjectTemplate once but it does 
>> become an issue when you create the ObjectTemplate afresh every time. 
>> That is a silly thing to do, though; it misses the point of templates. 
>>
>

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