Skip to content

Instantly share code, notes, and snippets.

@slickplaid
Created August 19, 2011 21:51
Show Gist options
  • Save slickplaid/1158103 to your computer and use it in GitHub Desktop.
Save slickplaid/1158103 to your computer and use it in GitHub Desktop.
Testing Memory Usage
// testing memory usage
function readableBytes(bytes){
var s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];
var e = Math.floor(Math.log(bytes)/Math.log(1024));
return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+' '+s[e];
}
function memUsage(){
var mem = process.memoryUsage();
var rss = readableBytes(mem.rss);
var vsize = readableBytes(mem.vsize);
return console.log('rss: '+rss+', vsize: '+vsize);
}
setInterval(memUsage,10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment