Node.js: FATAL ERROR: Ineffective mark-compacts near heap limit (JavaScript heap out of memory)
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Immediate Remediation
bash
# Increase V8 max old space to 8GB (8192MB) in your terminal or build script: export NODE_OPTIONS="--max-old-space-size=8192" # Or in package.json scripts: # "build": "NODE_OPTIONS='--max-old-space-size=8192' next build"
Root Cause Analysis
The Node.js process exceeded V8 default heap memory ceiling (approx 2GB–4GB depending on platform) during large bundle compilation or memory leak accumulation.
Verification & Guardrails
- Ensure the host machine or CI runner has sufficient physical RAM to accommodate 8GB.
- Check for unbounded array growth or unclosed file descriptors in custom build plugins.
Have a custom or uncategorized crash?
Run your trace through our in-memory client privacy sandbox for instant SRE remediation.