Node.js CLI Performance & Profiling

Node.js CLI performance cheat sheets for memory tuning, CPU profiling, heap analysis, coverage, and source-map-aware debugging.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Memory, Profiling, and Coverage
Increase max old space size
node --max-old-space-size=4096 app.js

# Raise the V8 heap ceiling in MiB.

Generate V8 profile log
node --prof app.js

# Record profiling output for CPU analysis.

Generate CPU profile
node --cpu-prof app.js

# Collect a CPU profile for DevTools analysis.

Generate heap profile
node --heap-prof app.js

# Record heap allocation data.

Write heap snapshot on signal
node --heapsnapshot-signal=SIGUSR2 app.js

# Generate heap snapshots on demand.

Trace GC activity
node --trace-gc app.js

# Print V8 garbage collection events.

Write V8 coverage output
NODE_V8_COVERAGE=./coverage node app.js

# Collect coverage JSON into a directory.

Enable source maps in stack traces
node --enable-source-maps dist/server.js

# Map stack traces back to original sources.

Recommended next

No recommendations yet.