Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patcher: remove wrappers when window is closed to avoid memory leaks #45

Closed
Infocatcher opened this issue Apr 26, 2013 · 2 comments
Closed
Labels

Comments

@Infocatcher
Copy link
Owner

Seems like garbage collector can't cleanup links to global extension object after window will be closed.

@Infocatcher
Copy link
Owner Author

Testcase:

var count = 25;
function leakTestPrototype() {
    for(var i = 1; i <= count; ++i) {
        var win = window.openDialog(location.href, "", "chrome,all");
        win.addEventListener("load", function loader(e) {
            win.document.documentElement.setAttribute("titlemodifier_normal", "[" + i + "/" + count + "]");
            win.removeEventListener(e.type, loader, false);
            win.setTimeout(function() {
                win.close();
                leakTestPrototype.__gen.next();
            }, 500);
        }, false);
        yield;
    }
    yield;
}
var leakTest = leakTestPrototype.__gen = leakTestPrototype();
leakTest.next();
  • open new window and close it
  • disable extension
  • open about:memory?verbose, run "Minimize memory usage" and refresh page
  • search for "privateTab" – shouldn't be found

@Infocatcher
Copy link
Owner Author

Looks fixed for me.
Tested on Firefox 20.0.1 and 23.0a1 (2013-04-25).

But there is another possible (and known) issue: if patcher unable to restore original function (in case of patches from third-party extensions), wrapper will not be completely removed to preserve functionality (but not memory).

Infocatcher added a commit that referenced this issue Apr 26, 2013
(part 1 for #46, enhancement for #45)
Infocatcher added a commit that referenced this issue Apr 26, 2013
Also "unload" listener, added in #45, seems to be useless
(part 2 for #46)
Infocatcher added a commit to Infocatcher/Download_Panel_Tweaker that referenced this issue Apr 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant