Skip to content

[Heroku] FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Published: at 12:45 PM (1 min read)

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}

Previous Post
[LeetCode] 50. Pow(x, n)
Next Post
[LeetCode] 49. Group Anagrams