Compare Revisions

Common causes of memory leaks in extensions

Change Revisions

Revision 49902:

Revision 49902 by nnethercote on

Revision 235077:

Revision 235077 by Nmaier on

Title:
Common causes of memory leaks in extensions
Common causes of memory leaks in extensions
Slug:
Extensions/Common_causes_of_memory_leaks_in_extensions
Extensions/Common_causes_of_memory_leaks_in_extensions
Tags:
Extensions, Add-ons, memory
Extensions, Add-ons, memory
Content:

Revision 49902
Revision 235077
n87      Bootstrapped extensions use a <code>bootstrap.js</code> comn87      Bootstrapped extensions use a <code>bootstrap.js</code> com
>partment. If you put a reference to anything within this compartm>partment. If you put a reference to anything within this compartm
>ent into a long-lived window object (such as <code>browser.xul</c>ent into a long-lived window object (such as <code>browser.xul</c
>ode>), JavaScript module or XPCOM component, the <code>bootstrap.>ode>), JavaScript module or XPCOM component, the <code>bootstrap.
>js</code> compartment will become a zombie.&nbsp; For example:>js</code> compartment will become a zombie. For example, the foll
 >owing code snippets — part of a <code>bootstrap.js</code> — will 
 >leak:
n96  // The new DOM node holding a reference to leakrefn96  // The new DOM node holding a reference to leakref will prevent
97  // will prevent that function object from being garbage collect97  // that function object from being garbage collected and hence
>ed and hence 
tt100}
101 
102function modifyDocument2(document) {
103  // The "body" DOM node holding a reference to leakref will prev
 >ent
104  // that function object from being garbage collected and hence
105  // will leak the whole bootstrap compartment.
106  document.body.someProperty = leakref;

Back to History