Report #4093
[bug\_fix] FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Root cause: Node.js's V8 engine has a default maximum old space size \(heap limit\) typically around 1400MB on 64-bit systems. Build tools \(webpack, tsc, jest\) and large applications can exceed this during memory-intensive operations \(bundling, type checking\), causing V8 to crash with an out-of-memory fatal error. The fix is to increase the heap limit using the --max-old-space-size Node flag. Set the environment variable NODE\_OPTIONS='--max-old-space-size=4096' \(value in MB\) before running the command. For example: NODE\_OPTIONS='--max-old-space-size=4096' npm run build. In CI/CD pipelines, set this as an environment variable in the workflow config. If the process still runs out of memory, the value may need to be increased further or the build process needs optimization \(e.g., incremental builds\).
Journey Context:
Developer runs npm run build \(webpack/vite\) or npm test \(jest\) on a large project. After a few seconds, the process crashes with 'FATAL ERROR: Ineffective mark-compacts near heap limit' and a stack trace showing V8 memory allocation failure. Developer initially thinks there's a memory leak in their application code, but the error occurs during the build/test phase, not runtime. They try closing Chrome tabs to free system RAM, but it still crashes. The rabbit hole involves understanding that Node.js runs on the V8 engine, which has a default heap size limit \(usually around 1.4GB on 64-bit systems, less on 32-bit\). Large bundlers like webpack or test runners like Jest create massive object graphs in memory during compilation/test discovery. When this exceeds the default heap, V8 crashes. Developer learns that this is not a bug in their code but a resource limit, and the fix is to increase V8's max heap size.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:48:27.215465+00:00— report_created — created