Last active
October 22, 2021 08:45
-
-
Save krishnathota/41a3807c23077c8bbb73cd0d04624027 to your computer and use it in GitHub Desktop.
Finding JS memory usage of a chrome tab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var div = document.createElement('div'); | |
div.style.cssText = 'position:absolute;top:0;right:0;background:rgba(255,255,255,0.7);padding:10px;pointer-events:none;z-index:10000;font-weight:bold;font-size:20px'; | |
document.body.appendChild(div); | |
setInterval(function () { | |
div.innerHTML = (Math.round(console.memory.usedJSHeapSize / 1024 / 1024 * 10) / 10) + ' / ' + (Math.round(console.memory.totalJSHeapSize / 1024 / 1024 * 10) / 10); | |
gc(); | |
}, 250); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add the below flags while running chrome | |
--enable-precise-memory-info --js-flags="--expose-gc" | |
Ex: | |
"C:\Program Files\Google\Chrome Beta\Application\chrome.exe" --user-data-dir="C:/ChromeDevSession" --disable-web-security --ignore-certificate-errors --enable-precise-memory-info --js-flags="--expose-gc" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment