一篇介绍Node垃圾回收机制的文章中,举了一段如下代码的示例来说明内存泄漏,望社区哪位朋友帮忙详细的解释一下啊!谢谢
var theThing = null
var replaceThing = function () {
var originalThing = theThing
var unused = function () {
if (originalThing)
console.log("hi")
}
theThing = {
longStr: new Array(1000000).join('*'),
someMethod: function () {
console.log('someMessage')
}
};
};
setInterval(replaceThing, 1)