Mha*_*ich 5 javascript iframe internet-explorer memory-leaks google-chrome
我正在尝试在多个浏览器中查找内存泄漏。
实际的理论是,这种内存泄漏与我们应用程序中的 iFrame 结合在一起。我们使用它们在我们的网络应用程序中实现像选项卡浏览这样的应用程序。
即使框架关闭并删除,所有浏览器似乎都会保留内容。
在 IE 中,私有字节不断增长(大约 2/3 的内存被清除,删除 iFrame 后仍保留 1/3),但堆保持不变,在 Chrome 中,我注意到(相同的)JavaScript 源的编译代码被保留。
我已经尝试将 iFrames src 设置为“about:blank”并清除 iFrame 中加载的大部分内容:
[...]
purgeFrame(this.content[0]);
this.content.remove();
[...]
function purgeFrame (iFrame) {
$(iFrame.contentWindow.document).unbind(); //remove listeners on document
$(iFrame.contentWindow.document).find('*').unbind(); //remove listeners on all nodes
$(iFrame).attr('src', 'about:blank');
iFrame.contentWindow.document.innerHTML = '';
iFrame.contentWindow.document.write('');
iFrame.contentWindow.close();
$(iFrame).remove();
if(typeof CollectGarbage == "function") {
CollectGarbage();
}
}Run Code Online (Sandbox Code Playgroud)
变化不大。我们使用 jQuery v1.12.4 和其他一些框架,如 DHTMLX 5.0.2。
对于此类问题有什么建议或经验吗?
| 归档时间: |
|
| 查看次数: |
1255 次 |
| 最近记录: |