问题
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