Created by Jerry Wang on Jul 22, 2015
test source code:
<html>
<script>
var theThing = null;
var replaceThing = function () {
var priorThing = theThing;
var unused = function () {
if (priorThing) { console.log("hi"); }
};
theThing = { longStr: new Array(10000000).join('Jerry'), //
someMethod: function () { console.log("g"); }
};
};
setInterval(replaceThing, 4000);
</script>
任务管理器里若干个chrome.exe 进程:

其中的两个代码当前Chrome加载的扩展程序:


观察到内存迅速增加:

通过比较两个heap profile,发现引起内存泄露是因为code里的closure:



![[端游] GGE2互通西游【精修梦江南】最新整理Win系端+安卓苹果PC三端互通+全套源码+搭建教程](https://cdn.jxasp.com:9143/image/20260408/53F3B6B3FF5B241EA5AFA7D519600A03.png)

















