Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AndrewBuntsev/e1f974ccf57b5da1eb77070a546935c7 to your computer and use it in GitHub Desktop.
Save AndrewBuntsev/e1f974ccf57b5da1eb77070a546935c7 to your computer and use it in GitHub Desktop.
JavaScript string memory leak
<html>
<body>
<script>
function createString() {
return "0".repeat(25 * 1024 * 1024).substring(0, 11);
}
var arr = [];
setInterval(function() {
let str = createString();
arr.push(str);
}, 500);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment