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插件中。