When deploying Node.js app to Heroku, I encountered the following error:
remote: <--- JS stacktrace --->
remote:
remote: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
This error occurs when your application exceeds the default memory limit for Node.js, causing the process to crash.
Solution
To resolve this issue, you can increase the memory limit for Node.js by setting the --max-old-space-size flag.
heroku config:set NODE_OPTIONS="--max-old-space-size=4096" -a #{your-app-name}