GC and jsdIStackFrame.script.functionObject.getWrappedValue();

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

GC and jsdIStackFrame.script.functionObject.getWrappedValue();

John J Barton
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?

Admittedly my evidence is indirect. With the line in, I see one script
for every page reload.  Else not.

Ok, its even more indirect: I have a table that has an entry per script,
filled when OnScriptCreated is called and removed when OnScriptDestroyed
  is called.  Its very hard to find a bug caused by an object not being
collected...

John.
_______________________________________________
dev-apps-js-debugger mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-js-debugger
Reply | Threaded
Open this post in threaded view
|

Re: GC and jsdIStackFrame.script.functionObject.getWrappedValue();

Adam L. Peller
> "John J. Barton" <[hidden email]> 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
_______________________________________________
dev-apps-js-debugger mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-js-debugger
Reply | Threaded
Open this post in threaded view
|

Re: GC and jsdIStackFrame.script.functionObject.getWrappedValue();

John J Barton
In reply to this post by John J Barton
Adam L. Peller wrote:

>> "John J. Barton" <[hidden email]> 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.
_______________________________________________
dev-apps-js-debugger mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-js-debugger