关键词搜索

源码搜索 ×
×

使用Chrome development tool查看代码内存泄露

发布2019-06-22浏览1300次

详情内容

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 进程:
    clipboard1
    其中的两个代码当前Chrome加载的扩展程序:
    clipboard2
    clipboard1
    观察到内存迅速增加:
    clipboard3
    通过比较两个heap profile,发现引起内存泄露是因为code里的closure:
    clipboard5
    clipboard4

    相关技术文章

    点击QQ咨询
    开通会员
    返回顶部
    ×
    微信扫码支付
    微信扫码支付
    确定支付下载
    请使用微信描二维码支付
    ×

    提示信息

    ×

    选择支付方式

    • 微信支付
    • 支付宝付款
    确定支付下载