Re: GC and jsdIStackFrame.script.functionObject.getWrappedValue();
"John J. Barton" <[email protected]> Wed, 08 Aug 2007 22:48:54 -0700
| Newsgroups | gmane.comp.mozilla.devel.jsdebugger |
|---|---|
| Message-ID | <[email protected]> |
Adam L. Peller wrote: >> "John J. Barton" <[email protected]> writes: >> In Firebug I had this line: >> var fn = frame.script.functionObject.getWrappedValue(); >> As far as I can tell this line prevented the script from being >> destroyed, even if I issue >> fn = null; >> directly after it. Is it possible? > > John, I haven't done much xpcom in a while, but it sort of makes > sense. If you're grabbing an xpcom object to pass across a language > boundary, the engine, being a good xpcom citizen, probably does an > addRef() to grab the object and to keep the object from being GC'd. > Since the XPCOM GC doesn't know anything about JS references or JS GC, > it would probably be up to you to call nsISupports::release() in this > instance. I don't see anything explicit about this in the docs, > however. I guess you'd have to do this anytime you deal with raw > nsISupports pointers across xpconnect? > > -Adam This getWrappedValue() thing seems to be JSD specific. No example of release() in Firebug and Vemkman seems to use the call a lot. So I have another theory....the 'frame' in var fn = frame.script.functionObject.getWrappedValue(); came over XPCOM from a Javascript-implemented component. Maybe the getWrappedValue() is ok in Javascript but not when the object is pulled through XPCOM? Firebug uses getWrappedValue() 20 places, maybe half on objects from the component side. I wonder if there are other leaks. Also I found that code like: if (script.functionObject.getWrappedValue() == fn) does not work (never true). Well, 'another theory', not necessarily a 'better theory'.... John.