Alex Fritze wrote:
> 
> Hi,
> I don't know whether this an xpconnect or js-engine question.
> I noticed that when you create an object in js through xpconnect, e.g.
> 
>  var inst = Components.classes["@my-company/my-class;1"].createInstance();
> 
> it never gets garbage collected until the current document is deleted, even
> if 'inst' goes out of scope or is explicitely set to zero.
> Is this by design? If yes, is there a way to force deletion?

This is not strictly true. If there are no references to the
object then it will be collected the next time the JavaScript gc
runs. This may not be until the document is unloaded. But it may
be sooner. It depends on things like JS memory load and how many
JS scripts get run (including things like event handlers). Or if
a docuement gets loaded in some other window. Currently there is
no mechanism to force a gc from JavaScript code. There is a bug
requesting this feature -
http://bugzilla.mozilla.org/show_bug.cgi?id=57343 - but no
consensus on where the method should be exposed and what code
should have access to it. I just added a comment requesting
others to give some opinions. Otherwise, my unilateral action is
to take no action.

John.


> 
> Thanks
> alex

Reply via email to