#2 ✓duplicate
Juriy Zaytsev

[Dup Trac #10782] Memory leak in Firefox

Reported by Juriy Zaytsev | April 11th, 2008 @ 05:03 PM

I wonder is there anyone else having same memory problem with us for prototype 1.6. Our app has massive memory leak on firefox after upgrade to 1.6.0. I have done a little bit analysis and find a way reproducing it consistently. I found once a Object having reference to DOM elements(directly or indirectly), and the object have been bind to some function using bind() or bindAsEventListener(), DOM elements referenced by the object will never get garbage collected. Here is a simple example

      <div id='container'> massive data that occupying memory... <div>
      <script type="text/javascript">
        Foo = Class.create({
          initialize: function(containerId){
            this.container = $(containerId);
          bar: function(){
            var dummyBind = function(){}.bind(this);

        new Foo('container').bar();

Then you find memory get increased every-time you do a refresh. The amount of memory that increased is depending on how much data you put in the 'container' div.

With my test data(2741 links in the container div), refresh this simple page for 100 times, make memory goes up to 183.59 mb. For prototype1.5, in the same condition browser only use 51.09 mb. I'm on Mac OSX tiger and my firefox version is

I am pretty sure it is the DOM element not get collected. Because if I do a window unload hook to null out object's reference to the 'container' div, the memory get collected backs.

I also test the page with leak-gauge, which proves the result I see through Activity Monitor. The process I take is I open the test page, then go to about:blank, then closed window. The result shows me both the inner window and document leaked. ( leak report for about blank is a mistake, that's simply because its the last page before the browser closed ). The report is like this:

prototype 1.5

Leaked 0 out of 13 DOM Windows
Leaked 0 out of 42 documents
Leaked 0 out of 5 docshells

prototype 1.6

Leaked inner window 171c2f50 (outer 16a03aa0) at address 171c2f50.
 ... with URI "file://localhost/Users/wpc/code/memory_leak/test.html".
Leaked inner window 17bfca90 (outer 16a03aa0) at address 17bfca90.
 ... with URI "about:blank".
Leaked outer window 16a03aa0 at address 16a03aa0.
Leaked document at address 25b1200.
 ... with URI "file://localhost/Users/wpc/code/memory_leak/test.html".
Leaked 3 out of 13 DOM Windows
Leaked 1 out of 41 documents
Leaked 0 out of 5 docshells

The attached files include the test page I use and js files both prototype1.6 and 1.5. When you try to switching to prototype 1.5, just change the script tag in the test.html to use prototype15.js. And a firefox runtime log also included as well.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

The Prototype JavaScript library.

Shared Ticket Bins

Referenced by