There's been some recent talk about memory leaks* in the JavaScript implementations of the major browsers. Here are three opinions from JavaScript experts:
-
Joel Webber: DHTML Leaks Like a Sieve - the article that started it all. He goes into some detail about why this happens.
-
Peter-Paul Koch of Quirksmode discusses this further: JavaScript Memory Leaks
-
Aaron Boodman (of Greasemonkey fame): DHTML leaks… not so much, actually. Aaron runs some tests and finds little leakage in Firefox, at least resulting from the circular references mentioned in the original article. On the other hand, IE indeed does leak like a sieve.
-
Mark Wubben's Event Cache automatically removes event handlers when a page is unloaded, solving IE's memory leakage problem.
* For those unfamiliar with the term, memory leaks refers to memory that is allocated but never freed. After thousands of operations with a minor leak, a significant amount of memory can be lost, resulting in slowdowns and crashes. This is the sort of thing that you usually don't have to worry about with JavaScript, but if you're writing something complex—like a video game, or a GMail—it becomes a concern.







1. The original blog has an update.
http://jgwebber.blogspot.com/2005/02/apology.html
Upon more careful examination, it seems that IE and Safari have some really bad memory leaks, but I can't seem to figure out what situations cause Mozilla to leak. I'm certain that there are Javascript constructs that cause it to leak, but I need to dig up some old code to find the circumstances that cause it. When I do, I'll let everyone know what they are.
Posted at 5:49AM on Dec 19th 2005 by anon