Monday, September 17, 2007

IE's Memory Leak Fix Greatly Exaggerated

So Microsoft (as reported here and here) recently released a "cumulative security update" for IE that fixes its egregious memory leaks. Sounds great. Even if it takes a while to get everybody updated, at least the problem is fixed and we can all stop bending over backwards to work around this problem in our libraries, right.

Not So Fast

Let's have a look at the actual knowledge-base article to see exactly what it says:

"... a Web page that uses JScript scripting code, a memory leak occurs in Internet Explorer. When you visit a different Web page, the leaked memory is not released."

So far so good. It even references the original "circular-reference" knowledge-base article, implying that this is indeed what is fixed.

When I saw this article, I nearly spilled tea all over the keyboard. They really fixed this issue? You mean I can untangle all the painful code in GWT that works around this issue, diligently cleaning up all its circular DOM references under all sorts of circumstances?

Settle Down, Beavis

Before I got too excited, I had to do a little gut-check. Did they really go back and make it possible for their garbage collector to chase references through COM objects? That would be wonderful, but I'm not holding my breath.

And it's a good thing, because there's basically no way in hell they did that. In fact, it turns out that all they did was write a little code to sweep the DOM on unload and clean up all the extant circular references on those elements. This means that all elements not still attached on unload are still leaked, along with the transitive closure over all references Javascript objects. In even marginally complex applications, that means you're still going to leak like a bloody sieve!

I put together a little test script to show this in action. Have a look in any version of IE, and watch its spew memory!

I'm With Alex ...

... on this one. This is more like a bad joke than anything else. I recognize that fixing IE's memory leaks is a really complex problem, but the fact that it's not being done is still more evidence that Microsoft is abandoning IE, at least as far as any real progress is concerned. I just wish they would come out and say it.

In the Meantime

Don't go ripping out that memory-leak cleanup code. And keep checking for leaks (perhaps with Drip).

6 comments:

Bwana Clyde Batty said...

Nice post. Regarding your point about MS abandoning IE as a reason for why they haven't cleaned the DOM garbage collection... perhaps it's because they have to delve into DLL's shared by the rest of the OS to clean this up. Somehow my hunch is that the sick joke is that by marrying their browser to the OS, they've stunted it's growth pattern to match that of their OS'. I.e. true fixes in the design will only occur once every millenium.

Itay said...

Hi Joel, I liked you article and I was wondering if you can help me with a question.
how can I creat an application with GWT to verify thath the memory does not leak with IE (6,7)

Jonathan said...

It probably shouldn't surprise anyone that Microsoft "fixes" aren't exactly what they're cracked up to be. Ask anybody who made the mistake of switching to Vista and is now trying to get it to work with any number of apps.

Jonathan
http://www.ebloggy.com/blog.php?username=acnetreatments

Mikee said...

Hi Joel,

Great blog - i'm glad you've revived it. It's going straight to my bookmarks/rss.

That Drip application you've written is brilliant. There's been so many times when i've written code and not been entirely sure if it's leaking or not. I can now finally say 'it is!'.

And congrats on the google job!

wow power leveling said...

MY wow power leveling
buy wow gold
my wow power leveling
BUY wow gold
CHEAP wow power leveling
my wow gold l_j

wow power leveling said...

wow gold
wow power leveling
buy wow gold
wow powerleveling
cheap wow gold
wow power level
gold wow
wow powerlevel
wow gold cheap
power leveling
wow gold buy
powerleveling
World of Warcraft Gold
world of warcraft Power leveling
wow power leveling
world of warcraft Powerleveling
lotro gold
power leveling wow
buy lotro gold
powerleveling wow
cheap lotro gold