Welcome to MSDN Blogs Sign in | Join | Help

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.

-JP

Published Wednesday, April 23, 2008 5:56 AM by JSBlog

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Microsoft news and tips » GC Improvements in JScript for Internet Explorer 8 Beta 1

# re: GC Improvements in JScript for Internet Explorer 8 Beta 1

Wednesday, April 23, 2008 10:54 AM by Koby Kahane

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.

# re: GC Improvements in JScript for Internet Explorer 8 Beta 1

Wednesday, April 23, 2008 5:14 PM by Mohamed A. Meligy

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?

# Interesting Finds: 2008.04.24

Wednesday, April 23, 2008 10:44 PM by gOODiDEA.NET

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

# Interesting Finds: 2008.04.24

Wednesday, April 23, 2008 10:45 PM by gOODiDEA

.NETVideo:WriteYourFirstSilverlightGameIncreasingtheSizeofyourStackWebCSS真的可以浮动么...

# re: GC Improvements in JScript for Internet Explorer 8 Beta 1

Tuesday, April 29, 2008 3:05 PM by William Edney

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!!

Cheers,

- Bill

# re: GC Improvements in JScript for Internet Explorer 8 Beta 1

Saturday, May 03, 2008 9:06 AM by Lenen

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

# re: GC Improvements in JScript for Internet Explorer 8 Beta 1

Wednesday, May 21, 2008 1:20 AM by anonymous

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

# re: GC Improvements in JScript for Internet Explorer 8 Beta 1

Thursday, May 29, 2008 5:53 AM by james w

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"?

# re: GC Improvements in JScript for Internet Explorer 8 Beta 1

Thursday, June 12, 2008 10:00 PM by TNO

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.

# re: IE8 Zoom Breaks Standard Jscript Technique For Measuring The Browser Viewport Window

Tuesday, June 17, 2008 8:23 PM by Richard Fink

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

FireFox's implementations is available at:

http://www.readableweb.com/forIEteam/IE8zoomanalysis.htm)

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.

# re: GC Improvements in JScript for Internet Explorer 8 Beta 1

Monday, July 14, 2008 6:55 AM by handan

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

eg:

<table>

<tr>

<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!

# re: GC Improvements in JScript for Internet Explorer 8 Beta 1

Saturday, July 26, 2008 8:56 AM by ergonomischewerkplek

Thanks for sharing! Nice article!

# re: GC Improvements in JScript for Internet Explorer 8 Beta 1

Tuesday, September 30, 2008 3:21 PM by Schiphol

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

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker