JSFiddle - React, Tailwind, and code Playground
HTML
<h2>Garbage collection measurement</h2>
<h3>Start Chrome via command line</h3>
<p>Linux:</p>
<code>google-chrome --enable-precise-memory-info</code>
<p>OSX:</p>
<code>open -a "Google Chrome" --args --enable-precise-memory-info</code>
<h3>Status:</h3>
<p id="p"></p>
JavaScript
var p = document.getElementById("p");
setInterval(function(){
var before = window.performance.memory.usedJSHeapSize;
// --- enter your code here ---
new Object();
// --- end of your code ---
var diff = window.performance.memory.usedJSHeapSize - before;
if(diff-40>=0)
p.innerHTML = (diff-40)+" bytes allocated in the loop";
else
p.innerHTML = "Are you sure you started chrome with the <code>--enable-precise-memory-info</code> flag?";
}, 100);