process.memoryUsage()

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

Since Node 0.x; memoryUsage.rss Node 15.6 Spec ↗

Syntax

process.memoryUsage()

Returns

object — Has rss, heapTotal, heapUsed, external, and arrayBuffers.

Examples

const m = process.memoryUsage();
console.log(Math.round(m.heapUsed / 1024 / 1024), 'MB heap');
Output
18 MB heap
console.log(process.memoryUsage.rss());
Output
48234496

Notes

`rss` is total resident memory; `heapUsed` is live V8 objects. `process.memoryUsage.rss()` is a cheaper call when you only need RSS. Sample periodically for leak detection rather than once.

See also