ArcGIS JavaScript API: IE Memory Leak Fix
Since version 1.2 of the ArcGIS Javascript API, we've noticed a strange issue in both IE6 and IE7. When zooming in, memory consumption of the iexplore.exe process takes a huge jump and reaches up to 800-900 megabytes. When the operation ends, it goes back down to 50-60 megabytes. This has caused us a great deal of sorrow, as it sometimes caused our users' systems to hang.
This post in the ESRI forums explains, and also provides a fix. Apparently, the upgrade to dojo 1.2 has caused this zoom-animation related issue. To fix it, you should create a javascript file with this text:
/*
* override the dojo 1.2, 1.3 version of dojo._setOpacity to revert back to the dojo 1.1 implementation
* this version doesnt allow multiple filters on an element, but it is free from the memory spike issue */
(function() {
var d = dojo;
if(dojo.isIE) {
dojo._setOpacity = function(/*DomNode*/node, /*Number*/opacity){
if(opacity == 1){
var filterRE = /FILTER:[^;]*;?/i;
node.style.cssText = node.style.cssText.replace(filterRE, "");
if(node.nodeName.toLowerCase() == "tr"){
d.query("> td", node).forEach(function(i){
i.style.cssText = i.style.cssText.replace(filterRE, "");
});
}
}else{
var o = "Alpha(Opacity="+ opacity * 100 +")";
node.style.filter = o;
}
if(node.nodeName.toLowerCase() == "tr"){
d.query("> td", node).forEach(function(i){
i.style.filter = o;
});
}
return opacity;
};
}
})();
Reference this javascript file from every page that has a reference to the Javascript API, and you're good to go.
Still, one can't help but wonder how the ESRI QA guys didn't notice this obvious shortcoming (which will be fixed at 1.4, they claim). Maybe they only used machines with lots of RAM. That's how we missed this at first... :)