Allocation failed - JavaScript heap out of memory #12165
-
I am working on a project which is developing with NextJs and ReactJs. Suddenly this project showing Allocation failed - JavaScript heap out of memory problem. I have tried all the resources online but, those are not working for me. I think, maybe something error occurred in next.config.js or webpack but, I am not sure about it.
|
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 9 replies
-
any updates on this yet ? |
Beta Was this translation helpful? Give feedback.
-
Hi ! Got the same issue :( NextJS: v12.1 I'm using next-transpile-modules: v9.0.0 I'm on MAC M1, the issue pop from nowhere, really frustrating |
Beta Was this translation helpful? Give feedback.
-
This is commonly caused when JavaScript has a lot of processes to handle, and the default heap memory allocated by Node. js needs more space to process the script you are currently running. Check out the solution, https://sebhastian.com/javascript-heap-out-of-memory |
Beta Was this translation helpful? Give feedback.
-
I dockerized my react application earlier and my environment variables were being pulled on runtime from the AWS secret manager, hence updating the build script in my package.json file worked for me. "build": "GENERATE_SOURCEMAP=false react-scripts build" I'm using react-scripts v4.0.1 |
Beta Was this translation helpful? Give feedback.
-
I spent a while banging my head against this, lamenting the hellscape that javascript has become ( In my case, deleting each I'll continue sacrificing small animals to the javascript gods in the hopes of improving my and your fortunes. Sharp knives with sharp handles smh |
Beta Was this translation helpful? Give feedback.
-
Mine crashed too. I deleted the .next folder killed the terminal and restarted the server again. It woked for me. |
Beta Was this translation helpful? Give feedback.
-
I've seen that in both dev and in a production build recently since the app dir was introduced, across multiple projects. What's more frightening, is that the dev server refuses to terminate in dev and keeps on allocating memory even faster when you try to CTRL+C it :D I frequently have to kill that using task manager or kill command (seeing this on both windows and linux). |
Beta Was this translation helpful? Give feedback.
-
I had the same bug and after hours of bashing my head against the wall found the error in my code. It was an infinite loop caused by a mistake in the JWT tokens and authentication flow, where a condition triggered the token function to repeat endlessly, eventually consuming all the memory. That is why increasing memory, deleting modules and cache and reinstalling everything also did not work. The cause might be different for those reading, but just a tip: check your code for infinite loops. |
Beta Was this translation helpful? Give feedback.
This is commonly caused when JavaScript has a lot of processes to handle, and the default heap memory allocated by Node. js needs more space to process the script you are currently running.
Check out the solution, https://sebhastian.com/javascript-heap-out-of-memory