New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Over here on the IE team we take leaks seriously. Extremely seriously. This is contrary to the popular opinion, but I'll let you make your own informed decisions. My new posting on MSDN is specifically designed to help you identify and fix several patterns of leaks. These range from your basic circular reference to your more complex (and more popular) closure based leak. Hopefully this new material can help you identify and exterminate all of the leaks in your code. If you have questions about the article feel free to post here or over on the IE team blog and I'll try to respond to any non-flaming responses ;-)

MSDN: Leak Patterns in IE

Published Monday, June 20, 2005 5:46 PM by Justin Rogers

Comments

Tuesday, June 21, 2005 9:59 AM by Chris Slatt

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Good to have you back! When do the posts on using Internet Explorer as a Game Engine start? ;)
Wednesday, June 22, 2005 3:57 AM by carter

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

very nice article, this will save a lot of people a lot of headaches :)

i do have one suggestion though, the images in the article are being resized by IE, leaving us with basically unreadable text. could you perhaps include a link to open them at full size in a new window? (i have sufficed with opening the image directly for now)

it would be nice if IE7 could do a "smart resize" on images the same way photoshop or paint shop pro resize images, instead or a pixel resize or bicubic resize or whatever its doing right now!
Wednesday, June 22, 2005 5:01 AM by Jon Boxall

# Required reading for anyone seriously considering AJAX

Great article - could have done with this 5 years ago...
Wednesday, June 22, 2005 5:38 PM by Andy Smith

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Hey Justin,

Those leaks...
From my understanding from another msdn article (can't seem to find it now), any leaks caused by an element in a closure would be cleaned as soon as the user navigates to a new page. Is that correct?
Wednesday, June 22, 2005 8:27 PM by Justin Rogers

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Image Sizes:
They should be fixed/getting fixed. They looked really good in Visio when I was making them. If they aren't fixed shortly I'll try and post alternates somewhere in addition.

Andy:
Closures leak across page navigations. The underlying problem is that there is a circular reference between an element in IE and a closure object in JScript. The only way to reclaim this memory is to recycle the process, so these shouldn't be taken lightly in production level script controls.
Thursday, June 23, 2005 9:06 AM by carter

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

the images themselves are fine when viewing them at full size (right-click -> properties on the image and get the direct URL), so you did a good job with making the images; it's just that viewing them in the article isn't that great because IE is scaling the images down due to explicit width/heights.

and since you're on the IE team, can you suggest the "smart" image scaling that i was talking about above? pixel/bicubic resizes look awful.
Saturday, July 02, 2005 6:41 PM by Nicolás Castagnet

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Very good article!!

Take a look at http://jgwebber.blogspot.com/2005/05/drip-ie-leak-detector.html. There is a very useful tool developed by Joel Webber to detect memory leaks.

But, I have another memory leak problem (in IE6) and I don't know how to solve it. It is very simple to reproduce. Create a page with this code:

<html>
<body >
<iframe id="testframe" src="about:blank"></iframe>
</body>
</html>

Load it in the browser and press Refresh several times (or use the function 'Blow Memory' in the tool that I mentioned above). Also happens if you define a loop that changes the page in the frame, for example:

var f = document.getElementById("testframe");
for (var i = 0; i < 10000; i++)
f.src = "about:blank"

I will appreciate a lot if someone could give me a clue to resolve this problem, or confirms me that it is a bug.

Thanks,
Nicolás Castagnet (ncastagnet@dlya.com.uy)
Tuesday, July 05, 2005 8:36 PM by eeevans

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Hey, did the source for the Terrarium ever get released?
Thursday, July 14, 2005 6:05 PM by Anonymous

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

In the long run, the best way to remove these leaks would be a fully managed (and thus, garbage-collected) web browser implementation. Since it would have other advantages (improved security, more flexibility to implement some of the weirdest ideas out of the W3C), it hope the IE team will investigate this possibility.
Maybe the development model for the IPv6 stack (first a project at MS Research, then integration into the mainstream product) could serve again (hopefully faster)?
Monday, July 18, 2005 7:38 PM by Martin

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Very nice and well written article. Congrats.

But as IE7 is moving towards standards complience, it would be better not to use the long-time-ago depreciated "language" attribut of the script tag.

So <script type="text/javascript"> and not <script language="JScript">

Bye,
Martin
Tuesday, June 05, 2007 12:04 AM by Silvanos

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Interesting...

Sunday, June 10, 2007 1:50 PM by Leonidas

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Sorry :(

Monday, June 11, 2007 10:14 PM by Kosmas

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Cool.

Wednesday, June 11, 2008 8:34 AM by Asad Raza

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

INH,

Hi,

Can you please tell me that if memory is also leaked by iframes? Im working on a project in which Remote Scripting has been done with iframes. It's multi-heirarchy tree, which is dynamically created. The iframes have been used to recieve input from the server without page refresh. I want to know that how much role is played by iframes in memory leaks and can Ajax provide a better solution and can it help in avoiding memory leaks?

Thanks.

Asad.

Thursday, December 25, 2008 6:36 AM by nick_trsita

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Friday, April 10, 2009 6:11 AM by nick_dronre

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Thursday, April 16, 2009 7:39 PM by DevareattyVaH

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

nice, really nice!

Saturday, May 23, 2009 1:06 AM by Aloke Saha

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

If u Want to build your career as a Plumber, please visit my site  

www.ableskills.co.uk/plumbing.htm

I think this Website helps u Very Much.  

Friday, June 26, 2009 7:05 AM by Anirban Das

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

I appreciate your thought.

www.personalized-custom-pens.com

Thursday, August 27, 2009 5:16 AM by Refanecyacawl

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

A counsellor being hailed as a knight said Tuesday he had no era to believe when he encountered a 17-year-old servant who detonated two quieten down bombs at a Northern California squeaky school while armed with a sequence catchword, sword and explosives.

Professor Kennet Santana, 35, is a man of a number of Hillsdale Treble School staffers credited with subduing the caitiff public schoolmate, who the long arm of the law bring to light walked into <a href=www.kaboodle.com/markythebuyer><font color=Black>buy erection package</font></a> the San Mateo circle Monday morning and establish dotty two water-pipe bombs in a hallway stingy a library.

Tuesday, September 22, 2009 3:51 PM by Rene Pally

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Hi Justin,

I found a memory leak at:

jscript!Parser::GenerateCode-->msvcrt!malloc

How can I can deal with this one?

Regards

Rene.

Wednesday, September 30, 2009 5:38 AM by fadaviddenden

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

this is the test message

please ignore this =)

------------

12358294867184757274

Tuesday, October 13, 2009 12:52 AM by gfy

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

fix the iframe memory leaks. this is absurb.

Friday, October 16, 2009 2:43 AM by poori

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

I have a first generation, and I don't think that I need to buy a 3G, the only thing that I am gaining is GPS. I just want to know what you think about the Iphone, if you own one or not.

________________

<a href="www.youtube.com/watch iphone 3g</a>

Friday, October 16, 2009 2:48 AM by poori

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

I really want an iPhone but the plans are ridiculously expensive and I don't feel confident buying one and trying to jailbreak it. What other great phones are out there?

________________

<a href="www.youtube.com/watch iphone 3gs</a>

Wednesday, October 21, 2009 6:28 AM by poori

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

I'm planning on getting the iphone 3G/3GS unlocked and i'm with 3 at the moment i have an unlimited usage plan and i was wondering if this would work with the iphone for example Applications, Safari, Maps etc?

________________

<a href="http://unlockiphone3g.webs.com">how to unlock iphone 3g</a>

Thursday, November 05, 2009 6:46 AM by Oberderferd

# re: New posting on MSDN about script leak patterns and how to fix them for anyone that builds dynamic web apps.

Leave a Comment

(required) 
(required) 
(optional)
(required)