Skip to: Site menu | Main content

XPlanner

Planning and tracking tool for agile teams following XP or Scrum

Javascript memory leaks Print

[excerpt from a TSS thread]

This is not specifically AJAX related, but since AJAX is most useful in conjuction with DHTML, I thought it worth mentioning. IE leaks memory when you have circular references between JavaScript objects and DOM objects (which are actually COM objects). This happens a lot with sophisticated DHTML applications that are modifying the DOM tree; event handlers are the main culprit.

For some discussion see:

http://www.quirksmode.org/blog/archives/2005/02/javascript_memo.html

http://jgwebber.blogspot.com/2005/01/dhtml-leaks-like-sieve.html

http://blogs.gotdotnet.com/ericli/PermaLink.aspx/f249659d-a3f1-4f6b-9ca3-3bbcc2df240e

An example solution to the problem:

http://novemberborn.net/javascript/event-cache

I have heard that there may also be similar problems with the event handlers of the XMLHttpRequest object itself.

Basically, I would not tackle a serious AJAX application without first having a reasonably sophisticated client-side framework for event management. You will need it anyway to hide the differences between the event models of the different browsers.