Garbage collecting in IE with ajax heavy applicaitons

Written by Alex Wolkov

We have a very heavy Ajax application on one of our sites. It reloads block of html on the site every 5 seconds or every user click, so obviously it’s intense.

I was approached by our QA and he told me that he’s computer freezes after some time the site is running.

And I started to investigate. Turns out we haven’t been collecting our garbage ourselves, and the “good” browsers took care of that for us.

Not IE though. IE was stuck after some 5-6 requests, and would just come to a halt on page.unload()

Manual garbage collecting to the rescue.


_temp = $.ajax(/* get loads of html data from ajax here*/);

_temp = _temp.replace(/*apply needed transformations before outputing code to the page*/)

$('#updated_div').html(_temp);

//garbage collecting - very important

delete _temp;

As you can see, one small line of code can help so much to your heavy Ajax application in browsers like IE.