您的位置:首页 > 运维架构

用drip工具测试并解决ie window.open 带来的内存泄漏

2011-12-27 20:17 399 查看
某一页面每打开一次,内存增长一次。达到一定程度后,页面假死,无法继续打开页面。

打开窗口代码如下。
function openEditor(){ 

var args=openEditor.arguments;

var MaxModalStyle = "status=1,scrollbars=1,width=" + (screen.width-15) + ",height=" + (screen.height-50) + ",left=0,top=10";

dgEditor=window.open("dd.jsp?kzh="+args[0]+"&nf=2009","",MaxModalStyle);           

return false;

}

考虑到和dgEditor对象没有释放代码有关系。代码修改为
var jdeditor = null;
function openEditor(){ 

var args=openEditor.arguments;

var MaxModalStyle = "status=1,scrollbars=1,width=" + (screen.width-15) + ",height=" + (screen.height-50) + ",left=0,top=10";
if(jdeditor!=null){

try{ 

jdeditor.close();

}catch(e2){

}

jdeditor = null;

}
jdeditor = window.open("dd.jsp?kzh="+args[0]","",MaxModalStyle);           

return false;

}

使用drip 工具检测, 内存增长大大减少。
起作用的是 jeditor.close(); 一句。
下图为drip 工具监测
注释掉 jeditor.close() 打开新窗口并关闭后内存陡增,使用jeditor.close() 后,再打开新窗口关闭,内存平稳。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  工具 测试 ie null function