V8

v8.getHeapStatistics()

Reports aggregate V8 heap statistics. It does not represent every native allocation or total resident memory. Compare trends under comparable workloads. Tested on Node.js 22.16.0. Example output (one line per entry): ["true true"].

Formal Syntax & Structure

nodejs syntaxnodejs
v8.getHeapStatistics()

Return Value

object

Heap measurements in bytes and counters.

Working Example

Example Snippetnodejs
import { getHeapStatistics } from 'node:v8';const s = getHeapStatistics();console.log(s.used_heap_size > 0, s.heap_size_limit >= s.used_heap_size);
Node.js Reference