-2
爲什麼此代碼會導致內存泄漏?內存泄露的原因
<html>
<body>
<script type="text/javascript">
document.write("Program to illustrate memory leak via closure");
window.onload=function outerFunction(){
var obj = document.getElementById("element");
obj.onclick=function innerFunction(){
alert("Hi! I will leak");
};
obj.bigString=new Array(1000).join(new Array(2000).join("XXXXX"));
// This is used to make the leak significant
};
</script>
<button id="element">Click Me</button>
</body>
</html>
它上市5從這裏http://www.ibm.com/developerworks/web/library/wa-memleak/
它解釋了它的權利下的代碼段。 – Carcigenicate
謝謝,但不明白,這就是爲什麼我在這裏問了一個問題 – vnbt