Is there a way to find out any information about objects being released using chrome dev tools

淺唱寂寞╮ 提交于 2019-12-11 08:45:19

问题


I have the following code:

var constructors=[];
var counter = 0;

function start() {
    for (var i=100; i> 0; i--) {
        constructors.push(new arrayValues());
    }

    if (counter < 10) {
        setTimeout(function() {
            start();
        }, 1000);
    }

    counter++;
}

function arrayValues() {
    this.values = new Array(10000000).join("x");
}

Which creates dummy array and creates memory leaks. This pattern is clearly see on timeline. But I can also see that there's a release of objects (marked with red line). Is there a way to find any information about the objects being released, for example, when or where they where created, etc.?

The question is not how to find the information by analyzing the code, but to find it using crhome-dev-tools


回答1:


The question is not how to find the information by analyzing the code, but to find it using crhome-dev-tools

If interpret Question correctly, you can use console.profile(), console.profileEnd(); Record Heap Allocation

See

profiling anonymous javascript functions (chrome)

Are arrow functions optimized like named functions?

How to detect the memory allocations that are triggering garbage collection in JavaScript?



来源:https://stackoverflow.com/questions/39728030/is-there-a-way-to-find-out-any-information-about-objects-being-released-using-ch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!