-5
I've found that all of these scripts, while doing the same thing create memory leaks,問題是,爲什麼?在IE6中創建內存泄漏的循環引用
這似乎是因爲循環引用。
<script>
function runme() {
var node = document.createElement("div");
node.onclick = function() {
node.style.background = "red";
}
document.body.appendChild(node);
}
</script>
或
<script>
function runme() {
var node = document.createElement("div");
node.onclick = function() {}
document.body.appendChild(node);
}
</script>
或
<script>
var node = document.createElement("div");
document.body.appendChild(node);
function runme() {
node.onclick = function() {}
}
</script>
或
<script>
var node = document.createElement("div");
node.onclick = empty;
document.body.appendChild(node);
function empty() {
}
</script>
到目前爲止發現了什麼? – dldnh 2012-03-25 11:57:20
IE6? IE6? ** IE6?!?** – 2012-03-25 12:09:15
我發現他們都是。但我不知道爲什麼。 – 2012-03-25 12:17:34