GC Improvements in JScript for Internet Explorer 8 Beta 1

Hello Friends,

Today I am going to talk about some of the Garbage Collector improvement we have done. Actually the original fix was done in Script 5.7 (shipped with IE7/Vista and also available on down level platforms), which we further enhanced in JScript shipped with IE8 Beta1.

So if you have gone through the Eric’s post on JScript Garbage Collector, you must have noticed following lines…

Actually what we do is keep track of the number of strings, objects and array slots allocated.  We check the current tallies at the beginning of each statement, and when the numbers exceed certain thresholds we trigger a collection. “

“However, there are some down sides as well.  Performance is potentially not good on large-working-set applications”.

The three thresholds he talked about were fixed in previous versions of JScript. After each GC cycle, counters were reset to zero. Next time when they hit the thresholds, again GC was triggered and so on.

This was alright for small scripts as they never create lot of strings and objects and don’t take much time to execute. But in modern AJAX applications, lots of objects /strings/array entries are created and they live for long enough time. Since rate of object/string/array entry creation is too high in these applications, thresholds are hit quite often, GC is triggered but not able to collect anything because things are still alive and there is no garbage. Counters are reset, but within few statements they again hit the thresholds. GC is triggered again but very less is collected and so on.

So as you see, GC is not able to collect significantly, however it is triggered at fixed intervals (as thresholds are fixed). Each GC cycle proves to be costlier than previous one as more objects have been created since last GC cycle happened.

So to fix this problem, we made the three thresholds adaptive. After each GC cycle, we check if GC was profitable or not, meaning significant collection happened or not. If it was not, then we double the thresholds. If it was, then the thresholds are not changed. Obviously there is an upper bound on value of thresholds, beyond which they are not doubled even if GC cycle was not profitable. Also if GC cycle collected everything, thresholds are set to their initial values.

That’s it for now. Hope you enjoyed reading it.


Comments (32)

  1. Koby Kahane says:

    What about future plans in this area?

    A generational GC for JScript could be interesting.

    AJAX applications would also benefit greatly from JScript going JIT, like Mozilla is heading with the Tamarin project.

  2. Mohamed says:

    I really hate how this is going to sound but:

    In the Silverlight example showing the difference between JavaSCript (silverlight 1.0) and C# (Silverlight 1.1/2.0), the Javacript version was 3 times slower on IE 7 than Firefox 2.

    What’s the ratio now?

  3. gOODiDEA.NET says:

    .NET Video: Write Your First Silverlight Game Increasing the Size of your Stack Web CSS 真的可以浮动么? xUnit

  4. gOODiDEA says:


  5. William Edney says:

    JP –

    Thanks for these posts! I love the fact that you guys are making a kick-a** implementation of JScript!!

    A couple of questions:

    1. I assume you guys are running tests like Sunspider, etc. (John Resig of jQuery fame has some too) to test your performance of JScript. Everyone else is ;-).

    2. When IE8 is finalized and shipping, is this newer JScript engine also going to be available for ‘down-level’ clients (like IE7) similar to the current Jscript 5.7 patch?

    3. Is this gonna be known as JScript 5.8 😉 ?

    4. Can you guys fix the ‘Process Manager’ problem (I’m seeing it on Win XP, SP2, IE7) ? It ‘lies’ to you about how much memory the IE process is taking up, showing a huge amount of memory until you ‘minimize’ all IE windows. When you make the window visible again, the process shows that the memory is way down, usually about 50% of what it was before you minimized the window. It will slowing start to climb from there until you go through the same process. This doesn’t affect the functionality of the application, its just worrisome to users who think that your web app is chewing up a bunch of memory.

    Thanks again!!


    – Bill

  6. Geld Lenen says:

    Good improvements, I think. Is this something like multithreading technology? Or does MT work a lot different?

  7. anonymous says:

    So what version will ship with IE8 RTM? WScript 5.8?

  8. james w says:

    I understand that Microsoft is actively contributing to the es3.1 spec. This is useful.

    But where do you and Microsoft stand on ecmascript4 (es4)? There is a lot of good stuff in es4 even if initially it looks daunting. Javascript – even es3.1 – is not enough for the future of the web. Is Microsoft working on a "new language"?

  9. TNO says:

    What surprises me is that there was such a big rush to create that piece of crap called JScript.NET, but an almost opposite reaction to ES4…what gives? ES3.1 is a step in the right direction, but as Brendan Eich and others have stated many times, its just not enough.

  10. Richard Fink says:

    (A whitepaper explaining this problem plus a comparison with Opera’s and

    FireFox’s implementations is available at:


    At any zoom level other than 100% – a condition which can’t be detected via

    script in IE8 – the new Zoom breaks the one and only available, standard,

    time honored, and widely deployed script technique for detecting the size of

    the browser window viewport in Internet Explorer.

    That one and only method of detection available in IE – the values of

    document.documentElement.clientWidth/Height (Standards Mode) or

    document.body.clientWidth/Height (Quirks Mode) are rendered unreliable for

    this purpose as an unintended consequence of IE8’s new Zoom. Developers have

    been able to rely unquestioningly on these properties for this purpose for

    the past ten years. They no longer can.

  11. handan says:

    I do is to web map programming, the map shows that this is the use of the mosaic map TABLE




    <td> <img src = "0_0.png" </ td>

    <td> <img src = "0_1.png" </ td>

    <td> <img src = "0_2.png" </ td>

    </ tr>

    </ table>

    But when I open this page often do not show the picture, I must be in the picture of regional mouse click can show that, Firefox can be directly displayed without onclick, I do not know what it is because I am distressed!

  12. ergonomischewerkplek says:

    Thanks for sharing! Nice article!

  13. Schiphol says:

    I don’t understand the table. can you please explain?

  14. Great! Thanks for posting this info.

  15. Europallets says:

    Thanks for sharing, i’m still not amused about using IE, firefox is the new way of life.

  16. heey Thanks for that link mate

    I was looking for that

    and IE isn’t it more me neighter

    Firefox is way better.

  17. Heey yeah I agree on that one Fire fox is a way better and way more Easier program too work with it loads faster and IE is Slower at Loading and Downloaden.

  18. it’s an Very nice and informatic articel

    I enjoyd reading it.

    thanks for it!

  19. Great info, thanks for the post. Is Microsoft working on a "new language"? Has that been answered?

  20. Found this article after some research. Read through the comments, but I don’t understand the table posted by Handan. Thanks.

  21. You should check out the IE8 readiness toolkit.

  22. Very impressive implementation of JScript!!

  23. Excellent information. It is a very informative article. Still a big fan of IE.

  24. Fire fox is much better and a easier program too work with. In all it loads and downloads faster.

  25. Thanks for sharing! Nice article, but I am a big fan of FF, but since IE is updating I might change back.

  26. Recently switched back to IE, and MS has made huge improvements. Now with the browserwar coming up I am expecting great things and major improvements soon.

  27. IE8 is very very good! Count me in as a new user, as I switched back from FF to IE. Great work!

  28. Great work, i really love the outcome of IE8

  29. What surprises me is that there was such a big rush to create that piece of crap called JScript.NET, but an almost opposite reaction to ES4…what gives? ES3.1 is a step in the right direction, but as Brendan Eich and others have stated many times, its just not enough.

  30. Delphin Diva says:

    ES3.1 is a step in the right direction, but as Brendan Eich and others have stated many times, its just not enough. http://www.delphindiva.org

Skip to main content