Tag Archives: IE memory leak

Memory leaks due to iframes in IE (also how to file-upload via dojo)

1) Changing the src of an iframe in IE may cause later events to fire multiple times – once for each change of src.  See http://www.dynamicdrive.com/forums/archive/index.php/t-10589.html

jscheuer1
06-24-2006, 09:21 AM
Yeah, I see what you mean, big time slow down in IE. No problem in FF. I didn’t test any others. I Thought it might be a memory problem so I tracked memory usage in Task Manager. No real problem with memory usage but I noticed actual CPU usage was spiking and then getting pegged a 100%. The more I loaded pages into the iframe in IE after that the longer CPU usage would remain pegged at 100% and this corresponded exactly with the amount of time that the frame was blank. I then had a look at your source code and saw that you had commented out this line:

//currentfr.detachEvent(“onload”, readjustIframe) // Bug fix line

Those two little red slashes at the beginning make it a comment. Why did you do that? I’m like 99% sure that this is the problem as that is an IE specific line designed to prevent multiple instances of the resizing event. Without that line, each time you load something into the iframe an event gets attached to it. After 20 loads, you have 20 events all firing at the same time. Almost has to be it. Just remove the red slashes and you should be fine.

2) Alex Russell of DojoToolkit explains that memory problems can occur with IE in both DOM event handlers and XHR due to the browser’s reference counting mechanism not realizing that it can recover some closures after they’re no longer needed.  See http://alex.dojotoolkit.org/?p=528 (which also explains how dojo can be used for file uploads).