This is the current way of doing things. Of course, you only need to track the objects which need to have their destructors explicitly called; objects that are pure memory will be cleaned by the operating system.
Using a JavaScript dictionary might work, but it doesn't "sound" right, for some reason. I suppose you'd have to store the references in v8::External objects. My implementation uses the STL to hold the references. And unfortunately, you really do need a dictionary (as opposed to a much simpler linked list, for example). I have a feeling that there would be a performance penalty for storing the references in JavaScript, but this is entirely untested. Perhaps you could try a comparison between it and the STL (just for reference). Alex On Mar 22, 2009, at 7:44 PM, Joe Antoon wrote: > > I'm using V8 to run a single context, and I would like to implement > weak handle-based destructors for my C++ objects. My current > understanding of this is that these aren't guaranteed to be called at > program shutdown. So my current objective is to keep a list of active > objects, and delete them explicitly when the program ends. For this, > I would need a dictionary. > > However, I'm not really too keen to bring in STL maps, or Boost > libraries into my program for this one small task. In terms of > performance and memory footprint, would I be better off using that, > rolling my own dictionary, or using a Javascript object to keep a list > of callbacks? Is this even the best way of doing things? > > > Alex Iskander, TPSi --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
