[Greasemonkey] Re: GM & FF memory leaks?

Jeremy Dunck jdunck at gmail.com
Wed Feb 8 14:11:37 EST 2006


On 2/8/06, Tom Van Herreweghe <tomvanherreweghe at telenet.be> wrote:
> The idea of cleaning up your own garbage seems good to me. I have taken
> a look at the EventManager class of Andre, but I am not familiar with

EventManager is designed singleton-ish, so no need to instantiate it.

You do need to initialize it, though.
Include his code, then call this:
EventManager.Initialise();

Then use it as he described:
EventManager.Add(trigger, "click",  myOnclick,  false);

But you'll still want to clean up on unload:
window.addEventListener('unload', function(){EventManager.CleanUp();}, false);

... He's got a special case for unload vs. _unload; I'm not sure what
that's about.

> I have tried working
> with global vars in userscripts, but they are never available as a
> variable in a function.

Please clarify this statement.  They're there and useable, so there's
some misunderstanding.  Sample code, please?

> I can only use GM_setValue & GM_getValue. But
> unfortunately, those don't work with arrays.

Try this:
var anArray = [1,2]
GM_setValue('x', uneval(anArray))
var anotherArray = eval(GM_getValue('x'));

..uneval being the interesting piece, of course.


More information about the Greasemonkey mailing list