[dojo-contributors] IE7 leaks and testBench

Michael Smith savoyboy at gmail.com
Wed Aug 8 16:50:31 EDT 2007


Here's a link to an excellent article detailing this leak pattern in IE. To
my knowledge, this leak has not yet been fixed in IE7.

http://www.codeproject.com/jscript/LeakPatterns.asp

Note that this leak can occur ANY time a DOM node is created and an event
handler is attached to the DOM node before the DOM node is appended to the
document. So, this is broader than just the "temp" scenario that you
describe. It applies to programmatic DOM manipulation in general.

To be safe never add an onclick (or any other) event handler to a DOM node
before it has been appended to the document.

Cheers,
~Michael


On 8/8/07, Scott J. Miles <sjmiles at turboajax.com> wrote:
>
> So, it appears that IE7 still has a basic DOM-JS circular reference leak
> pattern. The variation in IE7 seems to be that it only occurs when the
> DOM node is not part of a document.
>
> We see this problem in spades in testBench because the created widgets
> are attached to a temp node that is never attached to any document.
>
> Inserting:
>
> +65 document.body.appendChild(tmpNode);
>
> into testBench makes the reported leaks go away (c.f.
> http://trac.dojotoolkit.org/ticket/3531 and
> http://trac.dojotoolkit.org/ticket/4046).
>
> I'm not sure how often this happens in real life, so this may be less of
> a problem than it appears.
>
> I would suggest that code that produces phantom nodes (and attaches
> events to them) should be responsible for making them go away (vs.
> trying to solve this in event code). Otoh, running the Dijit cleanup
> code in IE7 could provide a measure of blind protection (with some costs
> at unload-time).
>
> I did some basic Googling, but I didn't find any reference to this
> problem specifically on IE7 (although I seem to be pretty bad at writing
> Google queries).
>
> Regards,
> Scott J. Miles
> TurboAjax Group
> http://www.turboajax.com
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-contributors
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20070808/90fd3d40/attachment.htm 


More information about the dojo-contributors mailing list