public
Last active

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13
var lastUsedHeap = 0; // remember the heap size
 
function checkMemory()
{
// check if the heap size is this cycle is LESS than what we had last
// cycle; if so, then the garbage collector has kicked in
 
if (window.performance.memory.usedJSHeapSize < lastUsedHeap)
console.log('Garbage collected!');
lastUsedHeap = window.performance.memory.usedJSHeapSize;
}
 
setTimeout(checkMemory, 100); // test 10 times per second

Shouldn't setTimeout be setInterval?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.