I want to be able to keep track of how many arrays a certain program uses, so that I can figure out if unnecessary memory has been allocated.The problem I am running into is Javascript's construct that array literal []
does not trigger Array#constructor
. Is there another way for me to keep track of array usage? ES5 and/or ES6 and beyond.
var arrayConstructor = Array // store reference
window.arrCount = 0
window.Array = function() {
arrCount++;
return new Array();
}
var arr1 = new Array
window.arrCount // 1
var arr2 = []
window.arrCount // 1 : NOT WORKING!
Nearly every web browser has a javascript profiler. The purpose of a profiler is to keep track of memory usage, frame rendering speeds, CPU usage, etc.
For example, Chrome's memory profiler looks like this when recording the loading of the Stack Overflow's Top Questions page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With