Just implemented the changes you suggested. Works great and I will continue doing this in the future! The memory is WAY more stable and I now further understand the point of the ObjectTemplate now. I did still report this in the issue tracker, as I hope at least the effect of NewInstance() is documented (or made more visible if it already exists).
To Gautham B A, this problem can be solved by using an ObjectTemplate and persisting and reusing it instead of creating a new one every time needed. On Monday, May 1, 2017 at 11:41:46 AM UTC-4, Ben Noordhuis wrote: > > On Mon, May 1, 2017 at 5:20 PM, Brendan Bates <[email protected] > <javascript:>> wrote: > > 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. > > I'd create a single ObjectTemplate with one or more internal fields > for stashing data, cache the template in a Persistent<ObjectTemplate> > and instantiate it three times. The indexed property handlers then > look at the internal fields to figure out what they should > access/return. > > > 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'm not a V8 maintainer so I can't answer this but to me it seems like > reasonable behavior. The idea of a template is to share behavior > across multiple instances. > > A CL updating include/v8.h to explain the memory ramifications will > almost certainly be accepted. > -- -- 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.
