[Greasemonkey] Re: Memory Leaks

Andre gm at andrecgn.de
Wed Nov 9 15:13:32 EST 2005


Hi,

you are right. I add several event listeners for a newly created button. 
It is a div with:

     var trigger = document.createElement("div");
     trigger.addEventListener("mouseover", eh_onmouseover, false);
     trigger.addEventListener("mouseout", eh_onmouseout, false);
     trigger.addEventListener("click", eh_onclick, false);

How would I remove them? The refresh is done by the page, not by my code.

Andre

----- Original Message -----
From: Gareth Andrew <freega at freegarethandrew.org>
Sent: Mittwoch, 9. November 2005 14:47:31
Subject: Memory Leaks
> Hi, 
> 
> My guess is that you are adding a new event listener every-time the
> window gets refreshed, but never removing any.  If you call 
> removeEventListener before you refresh do you get any improvement?
> 
> Gareth.
> 
> On Wed, 2005-11-09 at 14:13 +0100, Andre wrote:
> 
>>From: Andrew Murphy <andrewm1986 at gmail.com>
>>Sent: Mittwoch, 9. November 2005 13:53:49
>>Subject: Memory Leaks
>>
>>>My memory usage can reach 200MB before firefox is so slow I have to open and
>>>close it again!
>>>
>>
>>I have found that kicking off my script by the "onload" event creates a 
>>much bigger memory leak that just calling it.
>>
>>Fortunately, my script can run ever before the event fires, so I removed 
>>that call, and the memory leaks got smaller.
>>
>>My script is used on a page that refreshed every 2 minutes. Over night I 
>>have found that FF is using in excess of 500MB and stopping FF actually 
>>frees 800MB of memory.
>>
>>Andre
>>
>>_______________________________________________
>>Greasemonkey mailing list
>>Greasemonkey at mozdev.org
>>http://mozdev.org/mailman/listinfo/greasemonkey



More information about the Greasemonkey mailing list