Skip to content

Instantly share code, notes, and snippets.

@PanMan
Created April 6, 2016 20:40
Show Gist options
  • Save PanMan/07192157a4edd68c98165686cd1d16e0 to your computer and use it in GitHub Desktop.
Save PanMan/07192157a4edd68c98165686cd1d16e0 to your computer and use it in GitHub Desktop.
Take some memory and release it to test the GC
var testString="0123456789";
setInterval(function (){
console.log("Mem:", Math.round(process.memoryUsage().rss/1000000), " Mb ", process.memoryUsage(), "Len:",testString.length);
}, 1 * 1000);
for (i=0;i<20;i++){
testString=testString+testString; //Double: 10 * 10 ^
}
//Now testString=10.000.000 characters, which is roughly 20 Mb.
setTimeout(function(){
testString="";
//Now back to 0;
},2000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment