我是JSONP开发的新手,我发现IE 7/8不会清理JSONP脚本占用的内存.运行几个小时后,这会在我的页面中导致非常高的内存消耗.
我浏览了互联网,发现大多数修复都是基于Neil Fraser的提示.从博客中可以看出,您需要使用类似的代码删除脚本中的所有属性
var tmp;
while (tmp = document.getElementById('JSONP')) {
tmp.parentNode.removeChild(tmp);
// this deletion will create error in IE.
for (var prop in tmp) delete tmp[prop];
tmp = null;
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,删除将在IE中创建"对象不支持此操作"的错误,并且它不会释放内存.
所以我的问题是如何真正释放我的JSONP脚本的内存?
我把我的测试代码如下:
Testing.html
<html><head></head><body><script>
var script,
head = document.getElementsByTagName('head')[0],
loadCount= 0,
uuid= 1,
URL= "memleaktest.js?uuid=",
clearConsole = function() {
var con= document.getElementById("console");
while (con.childNodes.length)
con.removeChild(con.childNodes[0]);
},
log = function(msg) {
var div= document.createElement("DIV"),
text= document.createTextNode(msg),
con= document.getElementById("console");
div.appendChild(text);
con.appendChild(div);
},
test = { "msg" : null, …
Run Code Online (Sandbox Code Playgroud) 我们为鼠标点击手势实现了一个简单的InputBinding,代码如下:
<Image.InputBindings>
<MouseBinding MouseAction="LeftClick" Command="{Binding OpenDialogCommand}" />
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding OpenDialogCommand}" />
</Image.InputBindings>
Run Code Online (Sandbox Code Playgroud)
我们期望 WPF 能够识别 Left 和 LeftDouble 手势并执行相应的命令。但在实践中,我们发现首先评估左键单击,然后将双击的第二次单击视为另一次单击。由于我们的命令是打开一个对话框,因此双击将快速打开和关闭我们的对话框。
有人遇到过这样的事情吗?
谢谢。
S。