Share via


Leak Patterns

The information published in this post is now out-of-date and one or more links are invalid.

—IEBlog Editor, 21 August 2012

Justin Rogers one of our developers, just posted an article on MSDN where he discusses memory leaks with Internet Explorer. This article helps developers by explaining the issues and some best practices to fix web pages that leak memory. This includes such different types of memory leaks including circular references, closures, cross-page leaks and pseudo-leaks. The issue of memory leaks in IE has been the topic of recent discussion elsewhere and while we hope to improve in this area in future versions, this article should help developers today.

Thanks,
-Dave

Comments

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    I just don't care about the previous comment, because "everything that goes across a narrow spirit always take its dimension" (sorry for the translation from French :o)

    Now, just a note : why does the browser has to take care of bad pages ? Why don't we just say : this page is too ugly, don't show it, and learn HTML/DHTML before everything ?

    So, IMHO, the only thing to do is to check if a memory leak is to come (set a max memory limit for one page), and just run an alert such as the current "This script is running IE slow, should we stop it ?" alert for bad Javascripts, and that all.

    Adding many controls in For/while statements would only do one thing : slow IE for all scripts, including the good ones.

  • Anonymous
    January 01, 2003
    "So, IMHO, the only thing to do is to check if a memory leak is to come (set a max memory limit for one page), and just run an alert such as the current "This script is running IE slow, should we stop it ?" alert for bad Javascripts, and that all."

    Firefox already has this...

  • Anonymous
    January 01, 2003
    The article from Justin Rogers is great, but all figures in it are terribly scaled and almost not readable. Why can the browser not release all leaking objects when the user navigates away from the originating web page?

    BTW another very annoying bug in IE is that the user cannot always stop the navigation (download process) by pressing the stop button.

  • Anonymous
    January 01, 2003
    Why I should fix your bugs?

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    Quote: "Firefox already has this..."

    Can you back this up with proof?

    Please don't claim something if you don't back it up at the same time.

  • Anonymous
    January 01, 2003
    Please don't post a comment if you don't have anything interesting to comment.

  • Anonymous
    January 01, 2003
    With the leak patterns so well understood, surely the IE team should have patched these problems, thereby preventing the issue.

  • Anonymous
    January 01, 2003
    I suspect this entry will get flooded with users of a lesser mental capacity that will forget that IE executes code (ActiveX and Javascript) so it must deal with poor code in these languages.

    Although considering that the people behind this blog are well aware of it's energetic userbase, they could have worded this post a little better so as not to confuse IE's internal memory leaks, and leaks caused by parsing HTML/XML/JS/CSS/ActiveX/ETC

  • Anonymous
    January 01, 2003
    Seriously. If other browsers can handle this for us, so should IE.

    Javascript is a garbage-collecting language and HTML is a document markup language. There is no way an HTML/Javascript developer should be expected to do memory management.

  • Anonymous
    January 01, 2003
    Good article though. Very informative and easy to understand.

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    kL: do you understand what it's here about? I bet you don't. It's not about IE leaks but about excesive memory usage in JS. If you spoil your JS script, you fix it. Comprende?

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    > Now, just a note : why does the browser has to take
    > care of bad pages ? Why don't we just say : this
    > page is too ugly, don't show it, and learn HTML/DHTML
    > before everything ?
    Because Javascript and DHTML, by design, can only lead to leakage. See JGWebber's blog (http://jgwebber.blogspot.com/2005/01/dhtml-leaks-like-sieve.html) for more informations.

    From the same JGWebber, i'd also wish to point Drip (http://jgwebber.blogspot.com/2005/05/drip-ie-leak-detector.html), a wonderful IE leak detector and a quite fine tool, and as another leak-busting ressource you can check Novemberborn's Event Cache (http://novemberborn.net/javascript/event-cache)

    Looks like IE devs check the web development blogosphere, since IE's leakages have been quite an extensive subject for the past few weeks... shame they didn't link to blogged resources on top of the new MSDN article, though.

  • Anonymous
    January 01, 2003
    I have noticed IE pick up the odd circular script and offer to shut it down, and certainly there's less leaks than there used to be a few years ago. All good.

    One thing I'd like to see in IE7, purely for development reasons, is the ability to 'stop' script instantly with a keypress. I can't be the only person who's accidentally popped up a thousand alerts while debugging a recursive loop, and had to close the browser through task manager because they're modal. It'd have to stop existing timeouts, submits, navigates too. Just F12, bam, stopped dead, so I can examine the state of the page.

  • Anonymous
    January 01, 2003
    That first image in the article is completely illegible. Suggest you up the dimensions a bit, or bold the lines and text, so we can see what is going on.

  • Anonymous
    January 01, 2003
    Ya know, I'm ususally the first to point out the illogical nature of microsoft's actions, but to all of those pointing to IE as a sieve, keep in mind that Firefox has a GIANT memory leak as well. (although I'm told it's fixed in 1.1)

    Clearly, IE isn't alone in this, however one wonders why it's taken so long to correct.

  • Anonymous
    January 01, 2003
    I think that the biggest problem in IE is that when you put a lot of memory, IE goes slow and slow. FireFox don´t do that. Run the test below:

    <script type="text/javascript">
    var globalArr = new Array();
    for (var iter = 0; iter < 10; iter++) {
    var d1 = new Date();
    for (var i = 0; i < 10000; i++) {
    var blah = "string";
    }
    var d2 = new Date();

    for (var k = 0; k < 10000; k++)
    globalArr.push("a string");

    alert("Iteration [ "+iter+" ] globalArr count "+globalArr.length+" Time: "+ (d2.getTime() - d1.getTime()));
    }
    </script>

    Anyone have some good news about that!?
    Thanks!
    Thyago Liberalli
    thyago@gmail.com

  • Anonymous
    January 01, 2003
    Why isn't this blog listed under 'IE Blogs' on the left?

    And while we're at it why can't I aggregate all those blogs so I get a single RSS feed?

    planetplanet.org is excellent for this, of course it's uninnovative Free Software so you guys can't use it, but surely there's a EULA-heavy alternative?

  • Anonymous
    January 01, 2003
    Quote: "Firefox already has this..."

    Can you back this up with proof?

    Please don't claim something if you don't back it up at the same time.
    ---------------------------------------
    It has a function where if a script causes Firefox to perform slowly, it'll ask you if you want to abort it. I find it quite useful.

  • Anonymous
    January 01, 2003
    btw the rss feed is busted again.

  • Anonymous
    January 01, 2003
    I second the call for an IE Bloggers aggregator.

  • Anonymous
    January 01, 2003
    Yes, Firefox definitely ask the user to abort "locked up" scripts. Write one yourself and try, and you'll get your proof. :-)

    Regarding memory leaks, that's another matter and something I've found Firefox to have problems with before, especially after browsing image heavy sites like deviantart.com, but I think it has improved somewhat in the Firefox 1.1 builds. They also closed a long standing bug regarding this.

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    yes, firefox has poor behaviour with images. Especially large ones on old computers. However, the way it deals with javascript is quite delightful. About the only thing I've found that causes a significant amount of trouble is something like:

    while(1){alert("I am being a pain");}

    but of course this is not firefox's fault.

  • Anonymous
    January 01, 2003
    Please fix the closure problem, www.FreeTextBox.com gives me gray hairs over this!

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    May 19, 2006

    Welcome to The Desert Skies Podcast episode 13.  We were going to have a book review of a book on the...

  • Anonymous
    May 19, 2006

    Welcome to The Desert Skies Podcast episode 13.  We were going to have a book review of a book on the...

  • Anonymous
    September 14, 2007
    The comment has been removed

  • Anonymous
    June 06, 2008
    PingBack from http://thought.mobiforumz.com/2005/09/02/ie7-beta-chat-transcript-from-today/

  • Anonymous
    July 10, 2008
    PingBack from http://winzenz.mobiforumz.com/2005/09/02/ie7-beta-chat-transcript-from-today/

  • Anonymous
    January 22, 2009
    PingBack from http://www.hilpers.fr/399248-comment-detecter-le-changement-de

  • Anonymous
    April 27, 2009
    PingBack from http://www.zimbrablog.com/blog/archives/2006/04/will-there-be-a-web-20-browser-war.html

  • Anonymous
    June 08, 2009
    PingBack from http://insomniacuresite.info/story.php?id=8598

  • Anonymous
    June 12, 2009
    PingBack from http://cellulitecreamsite.info/story.php?id=7866