IE Hack: JavaScript Memory Leaks

The following is an article that I posted about one and a half years ago. I just repost it here as this is a hack to build up Java2Script Pacemaker.


Yes, I knew there was JavaScript memory leak in IE. I developed JavaScript codes mainly by Firefox/Mozilla, so I won’t notice the codes were leaking memory. These days I was developing J2S application in Eclipse, and found that the J2S applications were runnig more and more slowly in the J2S Console, which embed IE Browser widget. Once I did not think that memory leaking will make such poor performance. The slowness that I couldn’t stand finally taught me the lesson and I decided to fix the leaking codes.

Searching the net, I found that lots of articles were talking about this problem. I mainly read Justin Rogers’ Understanding and Solving Internet Explorer Leak Patterns. And after finishing the articles, I monitored one J2S SWT application (SWT Tree Snippet) while tring to refresh the page. I found 5 times of refreshing will leaking the memory from about 22M to 31M! Then I knew that maybe about 100M+ of memories was leaked in developing J2S applications when I felt the slowness of J2S Console.

I added a handler to the “onunload” event to break those circular references, codes like following:

* Only IE need to release the resources so that no memory is leaked
if (window.attachEvent) {
window.attachEvent (“onunload”, function () {
try {
org.eclipse.swt.widgets.Display.releaseAllResources ();
} catch (e) {
return true;

In the static method org.eclipse.swt.widgets.Display.releaseAllResources, I set those elements’ on* handlers to null and set those Controls’ parent and children to null. Things did work much better. But it was not fixed compeletely. Once I refreshed for a couple of times, I noticed that the browser will leak some 10~100k gradually. That was to say it will take about 10~100 times of refreshing for about 1M leaking and users will only perceive the slowness after about 1000 times of refreshing. So it was considered as working better.
I tried other ways to solve this leaking but did not get the right entrance.The current Java2Script library is almost built on closures of JavaScript, which will leak memory easily and hide leadking codes deep inside the whole codes. Replacing all those codes that using closures? No. Without closures, it’s somewhat hard to implement the Java Class inheritance.

It’s as Justin Roger’s saying “not all memory leaks are easy to find”. Memory leaking is just awful enough! 🙁

This entry was posted in Hacks. Bookmark the permalink.

41 Responses to IE Hack: JavaScript Memory Leaks

  1. Good post IE Hack: JavaScript Memory Leaks | Inside Java2Script however I am developing a issue we cannot are capable of register the rss feed, I am utilising google and yahoo reader fyi:) Enjoy your day Rob Rasner Myspace

  2. Do by no means ever enter your App Store or Play Retailer username and password in these program
    and sites!

  3. reverse phone lookup canada white pages reverse phone lookup business
    reverse phone lookup zurich

  4. D46MTFsXj says:

    942673 978113You seem to be very professional in the way you write.::

  5. 340866 946911For some cause the picture just isn

  6. 806271 90554Oh my goodness! an outstanding article dude. Thank you Nevertheless I

  7. 204566 751965hello admin, your web site page

  8. 864927 799674Hello, Neat post. There is actually a dilemma along with your internet site in internet explorer, could test this

  9. mca scam says:

    721839 937511This design is spectacular! You clearly know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (nicely, almost

  10. how to know whose phone number is this free whose phone number is this whose number is this free lookup whose number is this for free

  11. 196438 750385Spot on with this write-up, I truly feel this site needs significantly a lot more consideration. I

  12. 39885 839063fantastic post. Ne

  13. 804305 32132Hey! Very good stuff, please maintain us posted when you post something like that! 904145

  14. reverse lookup phone number cell free cell phone name lookup free cell phone
    lookup cell phone lookup by name and address

  15. 538430 10603You appear to be really skilled inside the way you write.::

  16. 655833 59706Hey this is kinda of off topic but I was wanting to know if blogs use WYSIWYG editors or in the event you have to manually code with HTML. I

  17. Songspk says:

    315283 129180I discovered your web site website on google and check a couple of your early posts. Preserve within the top notch operate. I just extra up your Feed to my MSN News Reader. Searching for toward reading far much more of your stuff afterwards!

  18. 523509 557889There is noticeably a lot of money to understand about this. I assume you

  19. 369825 869300Most appropriate the human race messages work to show your and present exclusive chance with special couple. Beginer appear system in advance of raucous individuals will most likely always be aware most of the golden value off presentation, which is really a person

  20. 67686 108240Most suitable boyfriend speeches, or else toasts. are almost always transported eventually by means of the entire wedding party and are nonetheless required to be really fascinating, amusing and even enlightening together. finest man

  21. mca says:

    681044 970415you are in point of fact a excellent webmaster. The site loading velocity is wonderful. It seems that you are performing any distinctive trick. In addition, The contents are masterpiece. you

  22. read here says:

    190677 740647A blog like yours ought to be earning a lot cash from adsense..-.,

  23. 926847 404437Does your blog have a contact page? I

  24. 476874 762363Hi this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I

  25. Magnificent web site. Plenty of helpful info here.
    I’m sending it to a few friends ans also sharing in delicious.

    And naturally, thank you on your sweat!

  26. los angeles says:

    It’s awesome designed for me to have a site, which is
    beneficial in favor of my experience. thanks admin

  27. ????????? says:

    I am not positive where you’re getting your information, but good topic.

    I must spend some time learning more or figuring out more.
    Thank you for wonderful information I used to be on the lookout for this information for my mission.

  28. Hi there, You’ve done a great job. I’ll definitely digg it
    and personally recommend to my friends. I’m sure they will be benefited from this site.

  29. online posao says:

    Very great post. I just stumbled upon your blog and wished to mention that I have really enjoyed surfing
    around your weblog posts. In any case I’ll be subscribing for
    your feed and I am hoping you write once more soon!

  30. here says:

    Thanks designed for sharing such a good thinking, piece of writing is
    nice, thats why i have read it entirely

  31. click says:

    I do trust all of the concepts you’ve presented to your post.
    They’re very convincing and can definitely work.
    Still, the posts are too brief for newbies. May just you please prolong them a little from next time?
    Thanks for the post.

  32. download says:

    Marvelous, what a blog it is! This blog presents useful data to us, keep it up.

Leave a Reply

Your email address will not be published. Required fields are marked *