[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();
</script>
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 2.0.0.11
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".
Summary:
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
-
Andrew Dupont April 11th, 2008 @ 05:06 PM
- → State changed from new to open
-
John-David Dalton April 15th, 2008 @ 04:14 AM
Does removing the element reference in "container" on unload
Event.observe(window, 'unload', function(){ myFoo.container = null; });solve the issue?
-
John-David Dalton April 15th, 2008 @ 04:18 AM
- → Title changed from Memory leak in Firefox to [Dup Trac #10782] Memory leak in Firefox
original ticket http://dev.rubyonrails.org/ticke...
-
Tobie Langel April 16th, 2008 @ 10:15 PM
- → State changed from open to bug_report
-
Tobie Langel April 18th, 2008 @ 01:17 PM
- → State changed from bug_report to bug
-
Tobie Langel April 18th, 2008 @ 01:17 PM
- → Assigned user changed from to Tobie Langel
-
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
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.
