Last Updated: February 25, 2016
·
5.713K
· jonykrause

Measuring JavaScript Heap

To have access to the JavaScript runtime heap open Chrome with the following flag:

open /Applications/Google\ Chrome.app/ --args -enable-memory-info

After doing so, you have access to the JavaScript heap:

// currently used heap
window.performance.memory.usedJSHeapSize;

// total heap
window.performance.memory.totalJSHeapSize;

Found this very interesting to play around with. More detailed information can be found here: http://buildnewgames.com/garbage-collector-friendly-code/