Subj : Re: custom object lifetime question. To : netscape.public.mozilla.jseng From : Chris Tchou Date : Wed Jul 21 2004 01:42 pm "Brendan Eich" wrote in message news:40FD3626.1010804@meer.net... > donteventthinkaboutit@sbcglobal.net wrote: > If you use JS_DefineObject, you are (a) creating a new object; (b) > binding it to another object by defining a property in that other object > whose value is a reference to the new object created in (a). If you no > longer need the object created in (a), you need *at the least* to make > the object in which you defined it as a property value become garbage, > or else delete the property defined in (b). What if an object you created, "A" has a dependence on another object "B" that isn't reflected in the properties of A (i.e. no property of A is a reference to B)? Is the best way to inform the GC of this to use JS_AddRoot(B) in A's constructor (and a corresponding JS_RemoveRoot(B) in A's destructor)? .