Mahn Mahn - 5 months ago 42
Node.js Question

What do the return values of node.js process.memoryUsage() stand for?

From the official documentation (source):


process.memoryUsage()

Returns an object describing the memory usage of the Node process
measured in bytes.

var util = require('util');

console.log(util.inspect(process.memoryUsage()));


This will generate:

{ rss: 4935680, heapTotal: 1826816, heapUsed: 650472 }


heapTotal and heapUsed refer to V8's memory usage.


Exactly what do rss, heapTotal, and heapUsed stand for?

It might seem like a trivial question, but I've been looking and I could not find a clear answer so far.

Answer

RSS is the resident set size, the portion of the process's memory held in RAM (as opposed to the swap space or the part held in the filesystem).

The heap is the portion of memory from which newly allocated objects will come from (think of malloc in C, or new in JavaScript).

You can read more about the heap at Wikipedia.