IE7 Garbage Collection Issues with many JavaScript objects and growing strings


News: IE7 Garbage Collection Issues with many JavaScript objects and growing strings

  1. I created a sample to show the performance difference between AJAX calls using XML vs. JSON. In that sample I came across a huge performance problem in IE7 (probably even worse in IE6) caused by too many and too large JavaScript objects. Newer browsers (IE8, FF, Chrome, ...) have better JavaScript engines and better GC approaches. But be aware of too many objects, too large object arrays and too large strings in IE7 as it heavily impacts JavaScript performance.

    Get access to my sample and read my analysis including graphs and comparisons to other browser at Garbage Collection in IE7 heavily impacted by number of JavaScript objects and string sizes.

    Threaded Messages (4)

  2. Ajax and Javascript objects[ Go to top ]

    Good article Andreas!

    Last year I gave a talk at TheServerSide Symposium on Browser Project in Ajax Applications. I used PushToTest TestMaker to drive an Ajax application on IE 6 and 7 and on Firefox 3. I did the research to learn why some Selenium tests of Ajax applications were running at 3 minutes while the same test on a different browser took 30 minutes. The results showed the performance problem from the outside. With dynaTrace Ajax Edition I can also look at the problem from the inside. Nice!

    The slides from my research are here:

    And TestMaker 5.4 open source test automation is available at:

    We really have to get dynaTrace Ajax Edition to observe pure paths coming from HtmlUnit.


  3. Hi Frank
    Good request - makes perfect sense. I also run the dynaTrace AJAX Community and would like to ask you to post these requests on our Wish List on our community pages:
    This helps us to figure out what is required by our users and will influence our development efforts.

    Talk to you soon
  4. Stephen Hyland[ Go to top ]

    This problem with immutable strings has been known about for many years.. Basically, you can't keep appending to strings. Instead use the following Javascript StringBuffer implementation in all your code. It is from an article in 2007.

    function StringBuffer() {
    this.buffer = [];

    StringBuffer.prototype.append = function append(string) {
    return this;

    StringBuffer.prototype.toString = function toString() {
    return this.buffer.join("");

    var buf = new StringBuffer();


  5. Stephen Hyland[ Go to top ]

    You are right - there are much more efficient ways to concatenate strings - I also linked to several different blogs of the guys from SitePen in my article.
    The interesting thing however was that having 1000 additional JavaScript objects in memory had an extremly negative impact on the same string operation sequenece in both of my scenarios. So - a) string concatenation are slow the way I did it but b) they were heavily impacted by GC activity caused by the 1000 additional JS Objects.