This project is archived and is in readonly mode.

#1144 ✓invalid

Possible event leak?

Reported by Tshepo | January 13th, 2011 @ 11:53 AM

The code below shows a simple test to simulate whether adding and removing events over a period of time creates a memory leak.
I'm not sure if this is the best way of doing the test but what appears to be happening is that the memory keeps going up and up.
The disposing is obviously not happening even thou I'm removing the event and setting the element to null.
I tested the code on IE8 and Google Chrome.

Can somebody please help me make sense of why the leak is happening. check out for a more detail example.

        var periodicalFunc = function() {

            var i = -1, l = 1000;
            var clickme = function() { };

            while (++i < l) {

                var e = new Element('div');
                e.addEvent('click', clickme);
                e.removeEvent('click', clickme);
                e = null;
        var periodicalID = periodicalFunc.periodical(100);

Comments and changes to this ticket

  • Christoph Pojer

    Christoph Pojer February 2nd, 2011 @ 08:15 PM

    • State changed from “new” to “invalid”

    In order to clean up an element with MooTools you need to call "destroy" on it. Just nulling the variable doesn't mean it gets garbage collected.

  • Tshepo

    Tshepo February 3rd, 2011 @ 04:51 AM

    Thank you for responding.

    I called the destroy function on the element and it still leaks on IE, but it doesn't for chrome any more.

    Is there something extra I need to call for IE?

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket