0
Microsoft documentation和W3C documentation都没有提到泄漏。单元格属性泄漏Internet Explorer上的内存?
它发生在动态创建的行上。这对我们来说是一个问题,因为我们有一个单页Web应用程序,通过ajax定期更新表格,最终iexplore会消耗所有内存和Windows。
重现:
function process() {
var row = document.createElement('tr');
var cell = document.createElement('td');
var text = document.createTextNode();
// doesn't matter order of these lines:
row.appendChild(cell);
cell.appendChild(text);
// this leaks on IE8/9:
var x = row.cells;
// this alternative doesn't:
//var x = row.getElementsByTagName("td");
setTimeout(process, 10);
}
process();
http://jsfiddle.net/5wzW2/1/ (本的jsfiddle网站无法在IE8的工作,因此张贴上面的代码)。
iexplore的监视内存使用量在任务管理器中每分钟增加大约一个MB。不在FF18/Chrome24中。
任何想法为什么,或者最好做什么?
Microsoft's bug reporting page似乎被打破。我的解决方法是将.cells
替换为.getElementsByTagName("td")
,例如在tablesorter插件中。