V8
v8.getHeapSpaceStatistics()
Returns measurements by heap space. Space names, presence and ordering can change across V8 versions; avoid depending on a fixed list. Tested on Node.js 22.16.0. Example output (one line per entry): ["true true"].
Formal Syntax & Structure
nodejs syntaxnodejs
v8.getHeapSpaceStatistics()Return Value
object[]
Per-space statistics.
Working Example
Example Snippetnodejs
import { getHeapSpaceStatistics } from 'node:v8';const spaces = getHeapSpaceStatistics();console.log(spaces.length > 0, spaces.every(s => typeof s.space_name === 'string' && s.space_used_size >= 0));