OS

os.totalmem()

Reports total system memory in bytes. It is not necessarily the memory limit of a container or the Node heap limit. Convert units explicitly and avoid sizing a service from this number alone. Tested on Node.js 22.16.0. Example output (one line per entry): ["true"].

Formal Syntax & Structure

nodejs syntaxnodejs
os.totalmem()

Return Value

number

Total memory bytes.

Working Example

Example Snippetnodejs
import os from 'node:os';console.log(Number.isFinite(os.totalmem()) && os.totalmem() > 0);
Node.js Reference