Slashdot Mirror


Plugging Internet Explorer's Leaks

jgwebber writes "If you're developing DHTML web apps, you probably already know first-hand that Internet Explorer has horrendous memory leak issues. You can't not run on IE, so you've got to find a way to plug those leaks. So I've created a tool to help you find them. So until Microsoft decides to fix its browser architecture (ha!), at least we can keep it from blowing huge amounts of memory."

39 of 480 comments (clear)

  1. How about firefox? by moz25 · · Score: 4, Interesting

    Is such an approach also useable for finding firefox leaks? As a user (not developer, alas) I'm noticing that it invariably gets sluggish after some period of time, even with few pages open.

    1. Re:How about firefox? by madaxe42 · · Score: 4, Interesting

      I'm fairly certain there's a leak somewhere in teh FF javascript handler - I've noticed memory usage rocketing on some pages which use JS.

    2. Re:How about firefox? by Anonymous Coward · · Score: 2, Informative

      Is such an approach also useable for finding firefox leaks?

      Doubtful. This is targeted at a very specific memory leak that Internet Explorer is known to have.

      As a user (not developer, alas) I'm noticing that it invariably gets sluggish after some period of time, even with few pages open.

      Apparently Firefox 1.1 will fix a lot of these memory leaks. You can try out "Deer Park" if you want a preview of Firefox 1.1.

    3. Re:How about firefox? by ssj_195 · · Score: 4, Interesting
      There were many, many leaks in Firefox, and many have been fixed for 1.1 (do a search on their Bugzilla for "memory leak"). Hopefully, the situation is now much-improved, but I suspect it will be the case that long periods of heavy-browsing will require you to to restart Firefox for quite a while yet. For this reason, I always recommend the Session Saver extension - makes closing and restarting Firefox less painful.

      Memory fragmentation is a big issue for modern desktop systems as the heap used by programs written in C/C++ can't be compacted, and most memory allocation systems weren't necessarily designed to support programs that would be continually allocating and deallocating memory for days on end. Robert Love gave a (fairly detailed and technical) talk on it at while back, with some suggestions for combating it on the Linux desktop, which I recommend to anyone who is interested. It's about 126MB, Ogg format.

      http://stream.fluendo.com/archive/6uadec/Robert_Lo ve_-_Optimizing_GNOME.ogg

    4. Re:How about firefox? by zootm · · Score: 2, Insightful

      Just to add on that point, it's probably worth noting that if you follow a pretty strict OO approach, most of the situations where these unchecked references occur become a lot less likely. There's still problems with non-terminating threads and things, people just have to be careful with the logic of their programs, which is a lot less common than I'd like it to be...

    5. Re:How about firefox? by Taladar · · Score: 2, Interesting

      Without being too familar with Javascript I am reasonably sure Javascript uses Memory too like any other programming language on the planet.

    6. Re:How about firefox? by Sinus0idal · · Score: 3, Insightful

      Yes but like Java, Javascript surely uses a garbage collection concept meaning it is the browsers responsibility to free memory, and any leaks are thus due to the browser.

    7. Re:How about firefox? by Evil+Adrian · · Score: 2, Informative
      --
      evil adrian
    8. Re:How about firefox? by theshowmecanuck · · Score: 2, Informative
      Yes but like Java, Javascript surely uses a garbage collection concept meaning it is the browsers responsibility to free memory, and any leaks are thus due to the browser.

      Bubble bustin' time! Garbage collection doesn't always live up to its reputation. I have seen Java apps leak memory like a sieve. This one project I was working at would start up a production (!) EJB container in the morning, and by 13:00, it would have run out of memory and crashed. I told them to fix their leaks. When they got over arguing that the garbage collector prevents memory leaks and checked it against a memory profiler... they started fixing the memory leaks and the problem was solve.

      In any case, I doubt that the garbage collection in the Javascript engines are anywhere near as sophisticated as in Java itself. So I would think it would be easier to leak memory. Anyway Mozilla has a bit of an article on this here.

      --
      -- I ignore anonymous replies to my comments and postings.
  2. Not Microsoft's Fault by robojamie · · Score: 4, Funny

    The true source of IE memory leaks?

    Korean outsourcing

  3. Pesty Internet Explorer Memory leak ... by weighn · · Score: 2, Informative

    here's something that helped me with this recently:

    --
    Mongrel News all the news that fits and froths
  4. Quick and dirty fix by Anonymous Coward · · Score: 3, Informative

    1. Open a new tab. Type "about:config" without quotes into the address bar and hit enter/click Go.

    2. Right-click anywhere, select New, then Integer. In the dialog prompt that appears, type:

    browser.cache.memory.capacity

    3. Click OK. Another dialog prompt will appear. This is where you decide how much memory to allocate to Firefox. This depends on how much RAM your computer has, but generally you don't want to allocate too little (under 8MB), but if you allocate too much, you might as well not do this. A good recommended setting is 16MB. If you want 16MB, enter this value into the dialog prompt:

    16384

    (Why 16384 instead of 16000? Because computers use base-12 counting. Thus 16 megabytes = 16384 bytes. Likewise, if you want to double that and allocate 32MB, you'd enter 32768.)

    4. Click OK to close the dialog box, then close all instances of Firefox and restart. If your Firefox still uses the same amount of memory, give it a few minutes and it should slowly clear up. If that fails, try a system reboot.

    1. Re:Quick and dirty fix by jrumney · · Score: 4, Funny
      Because computers use base-12 counting

      Please, tell us more about the fascinating workings of computers you seem to know so much about.

    2. Re:Quick and dirty fix by iceborer · · Score: 2, Funny

      (Why 16384 instead of 16000? Because computers use base-12 counting. Thus 16 megabytes = 16384 bytes...)

      I think you made a simple typo in this sentence. It should read Thus 16 megabytes = 1283918464548864 bytes.

  5. Has anyone used firefox? by MaGGuN · · Score: 5, Insightful

    Everytime I try to download ten things firefox goes up to 300 megs of memory usage and 99% cpu usage. And I took the screenshots to prove it.

    Frankly, I think you can find problems and features you hate in most programs of a certain size, what matters is that you find the tool for the job that you consider the best match for your needs.

    1. Re:Has anyone used firefox? by Errtu76 · · Score: 2, Interesting

      Haven't noticed the memory issue, but i can confirm the cpu usage being 99%. In my case it was caused by an embedded Flash movie on the site. As soon as i closed that (or even rightclicked within the flash movie and choose 'stop' or whatever) things went back to normal.

    2. Re:Has anyone used firefox? by molnarcs · · Score: 2, Informative
      Thanks for your comment! This has been driving me nuts. I installed firefox on various hardware, and on low and machines, it really really sucked. So I've been arguing for some time that the gecko engine (I notice the cpu-usage spikes as well) is really slow, compared to ie, opera or khtml. And always someone replied that he or she tried it, and it wasn't slow, like here. I had (and still have) little reason to doubt those comments, but they are run contrary to my own experience.

      Also, it's not on one machine, its on multiple machines running various OSs. The lower you go, the slower gecko gets. On a 533mhz machine (IBM PC 300) with 96Mb ram, firefox (and epiphany, tried both,hoping that epiphany might contain some gecko optimizations) was slower to render some pages while doing nothing else than opera was while compiling software in the background. The slowness is less pronounced on newer hardware, and curiously on windows! But I can still see it very clearly on my home pc (athlon xp 2400+ with 512RAM) if I do something CPU intensive in the background (like having multiple compiles running, downloading a huge file, listening to music at the same time). On an idle computer, you won't really see the difference, but if you have a cpu-monitoring tool running (I h ave kcpuload) you can easily notice that gecko to render the same pages with the same speed as khtml, grabs a lot more of the CPU than the latter. When those resources are scarce, it will be significantly slower than browsers built on other engines (Opera seems to kick ass along with khtml).

  6. best plug for it by sl4shd0rk · · Score: 2, Informative

    would be sealing it in a cement box and chaining the lid shut. I cannot believe that after all the
    vulnerabilities, bad experiences, and poignant advice, people still continue to use it.
    The alternatives aint perfect but they are a hell of a lot better.

    "Microsoft Internet Explorer 6.x with all vendor patches installed and all vendor workarounds applied, is currently affected by one or more Secunia advisories rated Highly critical" ...

    "Currently, 20 out of 81 Secunia advisories, is marked as "Unpatched" in the Secunia database."

    http://secunia.com/product/11/

    --
    Join the Slashcott! Feb 10 thru Feb 17!
  7. Making sites not run on IE by ajs318 · · Score: 2, Funny

    Actually, it's very easy to make a site not run on IE; as the following example shows.

    <?
    if (preg_match("/MSIE/i", $_SERVER["HTTP_USER_AGENT"])) {
    header("Location: http://www.mozilla.org/products/firefox/");
    exit();
    };
    ?>
    <html>
    <head>
    <title>This site will not display in Internet Explorer</title>
    .
    .
    .
    </head>
    <body>
    .
    .
    .
    </body>
    </html>

    --
    Je fume. Tu fumes. Nous fûmes!
    1. Re:Making sites not run on IE by kf6auf · · Score: 2, Insightful

      Don't be an @$$. Remember how annoying it was when people said that sites only displayed right in IE 5.5 or "better"? Yeah, you do. Did that get you to use IE? No, it didn't, unless it was your bank or something. So guess what? 90% of people won't go to your non-IE site. Period.

    2. Re:Making sites not run on IE by m4dm4n · · Score: 2, Insightful

      If the web designer is willing to go to the effort of excluding +-90% of browsers, the site probably isn't worth viewing anyway.

  8. Um..I'll have a shot by SimianOverlord · · Score: 3, Interesting

    because it's your job?

    I don't know why you geeks have such a downer on Microsoft for writing buggy software. If it didn't, do you have any idea about how many of you would be out of a job? The capitalisation that flows from Microsofts inability to write good operating systems is immeasurable. If it worked first time - would there be any engineers?

    It's sort of analogous to cruise liners. Used to be, because ships weren't terribly well made, a clipper had a huge crew of dirty, scurvey suffering swabbers. Nowadays, you have one captain and a big computer. Currently, IT graduates, computer consultants and systems administraters are that huge crew of disease ridden reprobates, serving on the creaking, rotten, old fashioned Microsoft vessel. And all you want is to be out of a job?

    Where's the logic in that??

    --
    Meine Schwester ist sehr, sehr reizvoll - Nietzsche
  9. First, is it a problem? by foreverdisillusioned · · Score: 2, Informative

    As I understand it, Firefox makes aggressive use of unused resources. If you're not having any slowdowns, then take a deep breath and realize that it's just doing what it's supposed to do.

    If you do have accompanying slowdowns, then you have a specific, rare problem. See the other replies you've gotten so far for suggestions.

  10. Don't Bother by FellowConspirator · · Score: 4, Insightful

    If you work around a problem, it hides from the user that the problem exists. The demand to have it fixed, therefore, dissipates and developers accept the onus to repeat work-arounds everytime they deploy something. Ultimately, the browser fails to improve, and the costs of errors are passed from the vendor (Microsoft) who never fixes the problem to the public (developers that waste time with work-arounds).

    Anyway, if you write things specifically for IE -- then you've already got a more serious problem that you have to address first. There's no excuse for what you already know to be dismal practice.

  11. Re:NOOB... by Negatyfus · · Score: 2, Funny

    Well, the memory remains allocated to the application. The thing is, it's a programming bug. The application allocates a piece of memory but never releases it, not even when it's not needed anymore. In a managed environment like .NET or JVM, a garbage collector periodically checks whether a certain piece of code or memory is still active, and when it's not it gets "collected" (freed).

  12. RTFA by Anonymous Coward · · Score: 2, Informative

    If any of you would RTFA, you'd find that the tool doesn't address leaks in Internet Explorer: It identifies web page code that cause leaks because the developer coded poorly. It doesn't matter what browser you use, people can still write web pages that will cause it to leak memory...

    1. Re:RTFA by jhurshman · · Score: 3, Informative

      Not exactly.

      It detects memory leaks that are due to the two separate garbage collection routines that IE employs for DOM objects on the one hand, and JavaScript objects on the other. The leaks occur when a developer creates a circular reference between a JavaScript object and a DOM object, which is a very easy and natural thing to do.

      For example, this creates a memory leak in IE:

      someNode.onmouseover = function() { this.style.color = "#f00" };

      That is "poor" code only in the sense that it trips over IE's DOM/JS circular reference memory leak problem. Other browsers (e.g., Firefox 1.0.4, Safari 1.3+) handle that code with no memory leaks.

      So while it may be true that it is possible to write a web page that will cause a given web browser to leak memory, this DOM/JS problem is particularly evil because it occurs not with some obscure, complex, or malicious coding practice, but with one that is very common and natural.

      --

      Do not speak unless you can improve on the silence.
    2. Re:RTFA by shumacher · · Score: 3, Insightful

      While I don't think MSIE is inherently evil, I think I could argue that a browser that allows web pages (a resource that should not be trusted) to cause memory leaks is itself flawed. Part of the browser's job is to not expose the user to risk or instability while interpreting documents of unknown maliciousness and quality.

  13. Re:NOOB... by Anonymous Coward · · Score: 2, Interesting

    On un*x the memory is returned when you close the app. Usually that is the case on NT based (XP is just NT 5.1) systems as well. In Windows 9x normal memory is often returned but USER/GDI (only 64k of each) memory that has been leaked is lost until the next reboot. In Windows 3.x once USER/GDI memory is used by an app it can never be freed even if the app is very well behaved and tries to free all memory on exiting.

  14. Worst IE hammering and flamebait article ever by Anonymous Coward · · Score: 4, Insightful
    It seems to me people are now attacking IE now from 3 major angles:

    • Memory and resource usage
    • Rendering and adhering to web standards
    • Security

    IMHO, It's laughable to mock IE for memory leaks when Firefox is X (where X > 1) times worse at sucking up and retaining memory.

    People have relentlessly said the reason IE is faster to load than IE on Win32 is because it is "embedded into the OS" and somehow brushed off this advantage in favour of it's debateable disadvantage in terms of security. What's next? Will slashdotters crying out something along the lines of "WOW! IE, an embedded part of the Windows, has memory leaks! What does that say for the Operating System? You better use Linux!"?

    IE may be guilty of having a buggy implementation of web standards such as CSS2.1 but during the browser wars wasn't it IE producing functionality that hadn't even been drafted by the W3C yet?

    Isn't that "Internet Explorer's architecture made this app fairly easy to build." as testament to the browser?

    This tool is interesing and useful for developers and I thank jgwebber for writing it as I'm sure it'll be useful even to lowly personal developers like me.
    On the other hand i'm a bit baffled as to why this article wasn't simply written as "Hey IE has memory leaks, checkout this new tool by jgwebber and see for youself. Let's discuss how sucky Internet Explorer is and cover up all the flaws in competitor browsers".

    It would have had the same effect as CowboyNeal's unnecessary "(ha!)"'s and claims of IE's "horrendous memory leak issues" without a link giving some evidence for these claims for those of us without first-hand DHTML development experience.

    I truly wasn't aware of any serious IE memory leaks..i'm going to, go off and Google for information now using the cumbersome Firefox. Any links would be much appreciated since CowboyNeal didn't bother.
    1. Re:Worst IE hammering and flamebait article ever by ArsenneLupin · · Score: 2, Interesting
      I truly wasn't aware of any serious IE memory leaks..

      You soon will... Even if jgwebber had the best of intentions when he wrote the tools (help Web developers write their javascript in such a way as too be easy on IE's leaky memory manager), I'm quite sure that is not what it will be used for in most cases. Quite the contrary! How long until we'll see a new flurry of "worst viewed with Internet Exploder" sites that throw your PC into a swap orgy seconds after they opened up and showed you their obgoats?

    2. Re:Worst IE hammering and flamebait article ever by dtfinch · · Score: 2, Interesting

      We have a kiosk running an html application in IE6. It uses lots of javascript and the front page reloads every couple minutes when idle. It's been running for 6 months on 64mb of ram with no issues. The same browser window has been open all that time.

      I remember one time writing a page which by accident, hit a memory leak in Mozilla (before there was a FireFox) which consumed about 1mb of ram a second. All the page did was draw a bouncing line, by creating a div for every line pixel of every frame and displaying them by setting the innerHTML property of another div. IE had no trouble with the page, except that it required some ugly hacks to make the page display correctly, unlike Mozilla, which displayed it perfectly as I had specified in the CSS, albiet leaky.

    3. Re:Worst IE hammering and flamebait article ever by mattOzan · · Score: 3, Insightful
      but during the browser wars wasn't it IE producing functionality that hadn't even been drafted by the W3C yet?

      Yes, and that was the whole damn problem.

      The point of HTML was universal interoperability (so Tim Berners-Lee's collegues could all read each other's stuff no matter what computer setup they had). But Microsoft sacrificed this in order to obtain control and market share. They encouraged web developers to use their proprietary markup, which forced people into using their browser if they wanted to access this content.

      This was not a benevolent gesture from Microsoft- it was nothing but a power-grab. Open, agreed-upon standards are the foundation of interoperability, and Microsoft always stands against this when it thinks it can monopolize a technology.

  15. Firefox Sucks (Memory) by lseltzer · · Score: 3, Informative

    >>It's laughable to mock IE for memory leaks when Firefox is X (where X > 1) times worse at sucking up and retaining memory.

    Thanks, I'm glad someone pointed this out. My system has been up for many days now and IE and Firefox are both consuming about the same amount (90-something MB).

  16. Keep on hammering, nobody's listening by toby · · Score: 3, Insightful
    during the browser wars wasn't it IE producing functionality that hadn't even been drafted by the W3C yet?

    You say that like it's a good thing(!)

    "Internet Explorer's architecture made this app fairly easy to build." as testament to the browser?

    No; for some pretty obvious reasons: one obvious one being, you exclude anyone not using that particular browser. I thought everyone realised that was a Bad Thing - or maybe you haven't been one of those people who can't use their online bank because the bank decided to arbitrarily depend on IE. One can only hope that accessibility laws will put an end to such stupidities.

    It's not surprising that both browser products have memory leaks. However one could reflect deeply on the differences in responsibility and approaches to remediation. In Firefox's case - being open source - you have complete transparency; you can file a bug on it, check the bug db, or even fix it yourself (don't laugh). In M$'s case, all you can do is kiss your money goodbye and hope they fix it "one day".

    The same goes for all the rest of their system, too. It is not always obvious what a disturbing abdication of rights using a closed system is. A friend recently told me of a Visual $tudio crash triggered by a few \b backspace characters in a print statement. Not such a big deal, I thought at the time; but I found myself reflecting on his story later. Eventually the true horror of the situation sank in, which is that we have to completely trust the ability and goodwill of the vendor to deal with any and all issues in their O/S. That is no small responsibility and there is not much evidence that M$ is capable of fulfilling their end of the bargain. I would postulate, after RMS of course, that no closed and proprietary system on the scale of M$ products can be adequately maintained by one vendor. And of course maintenance becomes irrelevant when major "rewrites" are involved, such as have been prescribed by Longhr0n to fix W1ndows' fundamental ills (ref Spolsky on rewrites, Things You Should Never Do).

    The thought that one has no recourse and indeed not even any way to inspect the system one uses (livelihood, etc), is deeply, deeply disturbing, and I again have to thank RMS for pointing out long ago what a dead-end that is, and for putting in place viable alternatives.

    --
    you had me at #!
  17. Re:Memory leaks are no longer excusable by joshdick · · Score: 2, Insightful
    Nowadays the state of the art has moved on and there is no excuse, none at all, for malloc/free.

    You've obviously never done any embedded programming.

    The low-level capabilities of C/C++ are there by design. That's why it contains the keywords union and register, for example.

    What's more, if everyone jumps on the virtual machine and garbage collection bandwagons, new problems pop up. Abstractions and convienences inevitably foul up, and often lead to poor programs overall.

    The onus for performance should rest with application developers, not compiler developers. Thus, the solution here is for developers to be properly trained and then to take responsibility for such matters as memory leaks. It looks to me that that's exactly what the Firefox team intends to do.

  18. great idea by Trailer+Trash · · Score: 3, Informative

    But your inflammatory tone would be really cool if our open source alternative in Firefox were somehow better. Right now, Firefox is using 373M on my computer (334M resident) with three windows open, none of which have anything bigger than this /. page. Mozilla is using 279M (I'm also running it) with a single page open. Firefox usually gets up to around 600-700M over the course of 3 or 4 days, after which it generally just dies. Otherwise, I have to kill it due to its slowness.

    Why not leave IE to Microsoft; put your effort toward something you can actually fix rather than being an ankle-biting ass.

  19. Re:Not on the to-do list by RzUpAnmsCwrds · · Score: 2, Insightful

    "Second, you add some new features. Like stealing compression code from Stacker, MS will just steal one of the "Tabbed browsing in IE" Plugins and muck the variable names up a bit."

    Come on. That's a cheap shot. There is no indication that Microsoft stole any code whatsoever for IE7.

    Ever wonder why Slashdot gets the reputation of being a bunch of crazy coots? Yep, it's people like you lobbing unfounded allegations against Microsoft.

    There are plenty of valid reasons to attack Microsoft. You don't need to make shit up.

  20. Re:NOOB... by ScrewMaster · · Score: 2, Funny

    Normally, it leaks out onto the surface upon which the computer is resting, however I have connected some surgical rubber tubing to my computer and have thus routed the outflow into the sump in my basement, where it is periodically flushed into the rain sewer. I'm not entirely sure whether this is environmentally sound, or not, and I would appreciate anyone with more experience in proper disposal techniques for leaked memory giving me a heads up.

    --
    The higher the technology, the sharper that two-edged sword.