Skip to content
This repository

Zombie compartments in GM_registerMenuCommand/GM_MenuCommander.onPopupShowing #1608

Closed
Ventero opened this Issue August 24, 2012 · 2 comments

2 participants

Ventero arantius
Ventero

Steps to reproduce:

  1. Install this script: https://gist.github.com/3041689
  2. Open any page
  3. Open the monkey menu, mouseover the "User Script Commands..." item
  4. Close the tab
  5. Check about:compartments for zombie compartments

Tested with GM 1.0, Firefox 15.0 and 17.0a1 (nightly from 2012-08-24).

The reason for this leak seems to be that GM_MenuCommander.onPopupShowing (via createMenuItem) attaches an event listener to the menu item, which via the command function keeps a reference to the content scope. Since the event listener is never removed, the scope and thus the compartment is held alive.

I'm only able to reproduce this once per Firefox instance though, not sure why.

(For reference, see also this comment on #1578.)

arantius
Collaborator

This depends on DOM cleanup. I thought removing the element from the DOM meant Firefox also cleaned up the event handlers' references.

But if you have two separate GM_rmc scripts affecting two different domains, you can see that the first page's menu item causes a leaked compartment. The second time you open the menu on a different domain, you should see the first compartment removed, and the second compartment stays referenced by that different menu item.

But that's not what I see. I see the first page that you ever opened the menu on stay, forever. Everything else gets cleaned up as expected. I don't have an explanation yet.

arantius
Collaborator

(The above: I've only tested in beta channel FF 15 so far.)

arantius arantius closed this in 007c4c4 August 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.