Wednesday, December 12th, 2007

window.createPopup leaks 80KB in IE 7

Category: IE

Frederico Caldeira Knabben, project manager of the FCK Editor, has been fighting some memory issues and found a new leak:

We at FCKeditor are constantly fighting against memory leak. We have already fixed several related issues, but we were still facing an expressive memory leak with IE7.

With some intuition, we were able to reduce the problem to a simple test case, and we have sadly found a new memory leak issue *introduced* with IE7.

Essentially, every call to window.createPopup() leaks 80Kb of memory. A test page can be found here:

http://www.fredck.com/bugs/ie/createpopupleak.html

In the default FCKeditor interface, we use six IE’s popups for all floating panels (toolbar combos and context menu). On pages with several editor instances, the memory increasing is substantial.

As far as we could understand it, there is no way to “cleanup” that leak. We strongly hope IE8 and even IE7 will have it fixed as there is no way to workaround it (I hope I’m wrong!).

Suggestions? Comments?

Posted by Dion Almaer at 5:49 am
13 Comments

++++-
4.4 rating from 32 votes

13 Comments »

Comments feed TrackBack URI

Are you aware of the the type of leak it is? Circular references? Closures?

Hopefully some JS guru can solve this issue. FCKeditor is a great product. It is good to see you taking these issues seriously. Thanks.

Comment by Site Smart — December 12, 2007

ehm… Did you look at the source to the linked page? The memory-leak is in window.createPopup, not anywhere in FCKeditor

Comment by erlando — December 12, 2007

IE strikes again. I’d point out though that FCK could really use a ditching of pop-ups any way. In-window divs such as those used in Ext JS wont throw security warnings and force people to disable their popup blockers. This might be a good opportunity to refactor your code :)

Comment by Jon Hartmann — December 12, 2007

@Jon: window.createPopup() has nothing to do with the popups we are used to see, which are instead created with window.open(). They behave instead much like a floating iframe, but have some special features (like floating outside the browser itself). Popup blockers don’t block them.

We have made some tests to avoid using window.createPopup, using floating divs or iframes instead. Then, we have another IE bug to fight here, because the cursor caret used on editing will always blink over floating elements, making the editor buggy to the user eyes. Using window.createPopup instead, we avoid this problem.

Of course, we’ll be investigating it further in the future. Thanks for your comments.

Comment by FredCK — December 12, 2007

Hmm, the leak doesn’t happen on my IE7 on Vista by default. It could be the google gears memory leak I found before since when I enable google gears it starts leaking just as you describe. Try disabling google gears if you have that installed to see what happens. Google has fixed this issue in their latest build.

Here is a discussion regarding that leak:
http://groups.google.com/group/google-gears/browse_thread/thread/83c298662c9e0c2/e8c47971f53b4eea?lnk=gst&q=leaks#e8c47971f53b4eea

Comment by Spocke — December 12, 2007

So, was Spocke right?
Should we change the title for this entry to Google Gears Leaks 80KB in IE7?
;)

Comment by skypoet — December 12, 2007

Never mind it still leaks memory. I just leaks more with the gears enabled, it could also be that I have the 64 bit version of the OS. It doesn’t leak 1MB each reload but like 20k hard to spot when the GC makes the values jump up and down.

Comment by Spocke — December 12, 2007

@Spocke : I have it confirmed from various sources, with IE7 on XP and Windows 2003. Probably this is not a bit issue with Vista 64-bit… lucky you :)

Comment by FredCK — December 12, 2007

@FredCK: Yeah, I just confirmed it my self. Tried IE7 on XP Pro and it leaks 1MB each reload but IE7 on Vista 64 bits leaks around 20k so the platform seems to make a difference. But that is a bummer that means event more platform combinations to test on. Isn’t there enough all ready. :)

Comment by Spocke — December 12, 2007

We have done some further research (it turned out that I wasn’t suffering now the leak so we searched for the differences), and as explained in http://alfonsoml.blogspot.com/2007/12/ie7-leaks-due-to-antiphising-protection.html the problem is only present if the Anti-phising protection of IE7 isn’t disabled. That also explains why the problem isn’t present in Drip or sIEve.

Comment by AlfonsoML — December 12, 2007

One question – whatever code you write, you need to make sure it will work in other browsers as well, especially Firefox. So when you are going to write JS code which will create a popup (may be a DIV based) in Firefox, why not use the same code for IE also? Instead of using something that is only IE specific, why not use generic code? Am I missing something here?

Comment by AotearoanBlue — December 13, 2007

@AotearoanBlue : check out my comment to Jon, I think 8 comments above this one.

Comment by FredCK — December 18, 2007

About the IE “Memory Leak” when creating a popup, it is not a memory leak in the meaning that Microsoft does not know why memory is being allocated, or why it is not being released. The approach of Microsoft to the IE Popup is that it is an object related to the browser itself, instead of the webpage creating it. The purpose is to give the popup the possibility to appear outside not only the webpage, but the browser itself. I have created an MSN-like popup-message using window.createPopup(), and the effect was that the user could see the popup even when the browser is minimized.

This is why the allocated memory is only released upon closing the browser. This is why closing the current TAB in IE7 will not do the trick either. So the reason of this memory leak is known, and the solution would be for Microsoft to re-think the way IE creates the popup object(something I doubt is on their top priority list).

However, this does not explain why FCK editor leaks so much memory. The way FCK is working, using divs will be troublesome, and catching the blur event from those divs to hide them is not as straightforward as some may think, specially on Firefox. So yes, keep the popup, but do not create several ones. Even if to the user several popup menus or messages will show, you should always use the same popup and simply re-place it and re-size it as needed – thus having only one window.createPopup() statement for each FCK instance or even only one per page if possible and thus having one 80 KB “memory leak” instead of more than the 1 MB currently observable.

On one of the websites I made, some pages bare 2 or even 3 instances of FCK Editor. Each time one of those pages open, the memory used by iexplore.exe increases of about 5 or 6 MB. After 1 hour of browsing the website, the thread reaches 500MB or so in memory size, and the browsers becomes very slow. The slightest link navigation or DHTML takes several seconds to execute. If the several instances of FCK appearing on the same page would only use one popup, the thread memory size would only reach about 100 MB at the end of the day and the visitor wouldn’t even notice it.

Comment by sanctous — July 14, 2008

Leave a comment

You must be logged in to post a comment.