Skip to content

Instantly share code, notes, and snippets.

@FrankGrimm
Created October 17, 2010 13:23
Show Gist options
  • Save FrankGrimm/630848 to your computer and use it in GitHub Desktop.
Save FrankGrimm/630848 to your computer and use it in GitHub Desktop.
var printMemoryUsage = function() {
var spawn = require('child_process').spawn,
getconf = spawn('getconf', ['PAGESIZE']);
getconf.stdout.on('data', function (data) {
var pageSize = parseInt(data, 10);
console.log('Page size: ' + pageSize);
var procOutput = spawn('cat', ['/proc/' + process.pid + '/status']);
procOutput.stdout.on('data', function (data) {
console.log("/proc/self");
data.toString('ascii').split('\n').some(function(line) {
if (line.toLowerCase().indexOf('rss') > 0) {
console.log(line);
return true;
}
});
});
});
}
printMemoryUsage();
console.log("process.memoryUsage():");
console.log(process.memoryUsage());
console.log("KB: " + (process.memoryUsage().rss/1024));
@stagas
Copy link

stagas commented Oct 17, 2010

process.memoryUsage():
{ rss: 168558592
, vsize: 8478720
, heapTotal: 3141632
, heapUsed: 2147252
}
KB: 165568

@stagas
Copy link

stagas commented Oct 17, 2010

{ rss: 195428352
, vsize: 8523776
, heapTotal: 3141632
, heapUsed: 2203364
}
KB: 191232
/proc/self
VmRSS: 11996 kB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment