Posted on 2012-08-15 16:53
oathleo 閱讀(1728)
評(píng)論(1) 編輯 收藏 所屬分類:
Web
下面2段代碼是測(cè)試代碼,IE9下測(cè)試
都有泄漏,非IE瀏覽器沒問題。困惑
每秒eval,400個(gè)方法調(diào)用;200多K的內(nèi)存泄漏,
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>eval 測(cè)試</title>
<script>
var afunction = function(_name,_mask){
return false;
}
var bfunction = function(_color){
}
var cfunction = function(_color){
}
var _action = function(){
for(var i=0;i<40;i++){
var _script = "if(afunction('111','222')) bfunction('0xCDCD00'); else if(afunction('111','222')) bfunction('0xCDCD00'); else if(afunction('111','222')) bfunction('0xCDCD00'); else if(afunction('111','222')) bfunction('0xCDCD00'); else if(afunction('111','222')) bfunction('0xCDCD00');";
_script += "if(afunction('222','333')) cfunction('0xCDCD00'); else if(afunction('222','333')) cfunction('0xCDCD00'); else if(afunction('222','333')) cfunction('0xCDCD00'); else if(afunction('222','333')) cfunction('0xCDCD00'); else if(afunction('222','333')) cfunction('0xCDCD00');";
var _func = new Function(_script);
_func();
}
}
window.onload = function() {
setInterval(_action,1000);
};
</script>
</head>
<body>
</body>
</html>
2.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>eval 測(cè)試</title>
<script>
var _action = function(){
var afunction = function(_name,_mask){
return false;
}
var bfunction = function(_color){
}
var cfunction = function(_color){
}
for(var i=0;i<40;i++){
var _script = "if(afunction('111','222')) bfunction('0xCDCD00'); else if(afunction('111','222')) bfunction('0xCDCD00'); else if(afunction('111','222')) bfunction('0xCDCD00'); else if(afunction('111','222')) bfunction('0xCDCD00'); else if(afunction('111','222')) bfunction('0xCDCD00');";
_script += "if(afunction('222','333')) cfunction('0xCDCD00'); else if(afunction('222','333')) cfunction('0xCDCD00'); else if(afunction('222','333')) cfunction('0xCDCD00'); else if(afunction('222','333')) cfunction('0xCDCD00'); else if(afunction('222','333')) cfunction('0xCDCD00');";
eval(_script);
}
}
window.onload = function() {
setInterval(_action,1000);
};
</script>
</head>
<body>
</body>
</html>