Memory leaks in torbutton
Hi, I noticed some memory leaks in torbutton. So, I tested with development branch, and they were still here. Those leaks come from pref observer not being removed during window unloading. When you use just one window, that's not a big deal, but if you use multiple, some javascripts objects are leaked each time.
Here is a patch to apply against last version (http://torbutton.torproject.org/dev/torbutton-current-alpha.xpi 1.1.6 30 Jul 2007)
PS: I noticed those leaks with leak monitor, a nice tool for xul developers: http://dbaron.org/mozilla/leak-monitor/
--- torbutton.js 2007-09-06 23:29:18.000000000 +0200 +++ /home/arno/.mozilla/firefox/qrp98gfd.tes/extensions/{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}/chrome/content/torbutton.js 2007-09-06 23:31:59.000000000 +0200 @@ -20,7 +20,7 @@ unregister: function() { if (!this._branch) return;
-
this._branch.removeOberver("", this);
-
this._branch.removeObserver("", this);
},
// topic: what event occurred @@ -838,6 +838,10 @@ Components.interfaces.nsIWebProgress.NOTIFY_LOCATION); }
+function torbutton_close_window(event) {
- torbutton_pref_observer.unregister(); +}
// Technique courtesy of: // http://xulsolutions.blogspot.com/2006/07/creating-uninstall-script-for.html const TORBUTTON_EXTENSION_UUID = "{E0204BD5-9D31-402B-A99D-A6AA8FFEBDCA}"; @@ -884,6 +888,7 @@ }
window.addEventListener('load',torbutton_new_window,false); +window.addEventListener('unload', torbutton_close_window, false); getBrowser().addEventListener("TabOpen", torbutton_new_tab, false);
[Automatically added by flyspray2trac: Operating System: All]
Trac:
Username: arno