Last Updated: February 25, 2016
·
6.2K
· 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/

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside