> > 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. >
I guess the only reason I would consider it a bug: shouldn't any Javascript local/persistent be fully cleaned up when it goes out of scope? If you create the Local<ObjectTemplate> in a HandleScope and the scope closes, you can't use that template anymore. I would also think any metadata or cache related to that scope would clear as well. I honestly don't know enough about v8 to make that assumption, but I assumed most things stored in a Local were memory leak safe. 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.
