JSFiddle - React, Tailwind, and code Playground

by Jaak Kütt

HTML

Inspect memory usage with the line #3 and notice it stacking up as gc doesn't let huge go <br><br>
<code>var small = huge.substr(0, 15);</code>  <br><br>

vs if you'd split it to an array and back again - the usage remains stable  <br><br>
<code>var small = huge.substr(0, 15).split("").join("");</code>  <br><br>

Is there a nicer way to unset huge?

CSS

code {
  color: #FF0000;
  border: 1px solid #333333;
  padding: 5px;
  margin: 10px;
}

JavaScript

function getSmallString() {
    return "x".repeat(20).repeat(1024).repeat(1024).substr(0, 15);
}
var smallStrings = [];
setInterval(e => {
    var str = getSmallString();
    console.log("+ " + str.length + " bytes???");
    smallStrings.push(str);
}, 1000);