arunoda / node-usage

process usage lookup with nodejs
MIT License
389 stars 93 forks source link

Incorrect vsize value #47

Open ev0rtex opened 9 years ago

ev0rtex commented 9 years ago

I am noticing terribly incorrect vsize values on my system (Ubuntu Server 14.04). For an example I have a simple js file where I do:

var usage = require('usage');

usage.lookup(process.pid, function(err, stats) {
  console.log(stats);
});

In the output I see:

{ memory: 16662528,
  memoryInfo: { rss: 16662528, vsize: 2805502836736 },
  cpu: 89.99999999476131,
  cpuInfo:
   { pcpu: 89.99999999476131,
     pcpuUser: 29.999999998253767,
     pcpuSystem: 59.99999999650753,
     cpuTime: undefined } }

That is giving me a vsize of 2.55TB. There is no way that makes sense.

Digging through the code I see that in lib/providers/linux.js it is multiplying the vsize it gets from /proc/[pid]/stat by the PAGE_SIZE. In the proc man page it says:

    vsize %lu   (23) Virtual memory size in bytes.

Seems to me that what I actually want is that raw vsize value without the multiplication.