[Greasemonkey] Re: GM & FF memory leaks?
John Plsek
jplsek at iinet.net.au
Thu Feb 9 19:56:33 EST 2006
Andre wrote:
>>
>> .... He's got a special case for unload vs. _unload; I'm not sure what
>> that's about.
>
> '_unload' is its own unload event listener that really gets
> registered. All the others from user code are named 'unload' and will
> be stored in the EventManger registry only in order to be called in
> 'CleanUp()'. They will not be registered in an addEventListener call,
> because there would be no guarantee, that they are called exactly
> once. In the original code they might get called twice.
>
> Andre
>
Actually, the history behind my usage of the "_unload" special case is
nothing to do with unload being called twice.
I don't recall where I originally snagged the ORIGINAL EventManager code
from, it had nothing to do with greasemonkey. I noticed when using it,
though, that the only "unload" code being executed was EventManagers own
- any unload events registered WITHIN THE SCRIPT were not being executed
.. so I hacked in the _unload type, and as part of the cleanup code, jst
before unregistering any unload event, call the registered function. So
as to avoid recursion when it came upon it's own unload event, stored
that with the type "_unload"
Of course, in later versions of greasemonkey and/or firefox, that
problem may have gone away, and you may end up, as Andre suggested, with
the unload events being fired twice (once by firefox, once by the
cleanup code) ... so, Andre's changes ensure that in either case, each
unload event only gets called once.
John
More information about the Greasemonkey
mailing list