Runtime

V8 libuv and runtime boundaries

V8 executes JavaScript and manages its heap; libuv coordinates event-loop facilities and asynchronous work. Node bindings connect JavaScript-facing APIs to native runtime and OS operations. A V8 isolate has its own JavaScript heap; worker threads use separate isolates. Objects become eligible for garbage collection when unreachable, but collection timing is not predictable. Some memory, including backing stores for buffers, is outside the ordinary JS heap. `v8.getHeapStatistics()` exposes heap information, while `process.memoryUsage()` gives process-oriented counters. A filesystem promise delegates work through Node and libuv, then a completion allows JavaScript to resume. Not every I/O operation uses the libuv worker pool: socket readiness can be handled by OS facilities. Distinguish public observations from implementation internals and avoid claiming one snapshot proves a leak. Do not infer a leak from one RSS reading, or assume every asynchronous API creates a new JavaScript thread. Sources: https://nodejs.org/download/release/v22.16.0/docs/api/v8.html; https://nodejs.org/download/release/v22.16.0/docs/api/process.html.

Formal Syntax & Structure

nodejs syntaxnodejs
v8.getHeapStatistics(); process.memoryUsage()

Working Example

Example Snippetnodejs
import {getHeapStatistics} from 'node:v8';import assert from 'node:assert/strict';const h=getHeapStatistics(),m=process.memoryUsage();assert.ok(h.heap_size_limit>0 && m.rss>0 && m.heapUsed>=0);console.log('heap and process counters available');
Node.js Reference