Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to allocate more memory to my Virtual Machine running on Fedora to avoid Heap out of Memory Error

I'm running Jenkins on a Fedora Virtual Machine and have an app created by create-react-app .

When I try to build for production on my local machine, after ~8 minutes, it does get compiled successfully (although with the message: 'the bundle size is significantly larger than recommended...'

However, when I run the same script during my Jenkins build process, I get the following error: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory.

The build script is as follows: npm run build-css && node --max_old_space_size=8192 node_modules/.bin/react-scripts-ts build && npm run copy-to-build.

My question is, how can I allocate more memory for my Virtual Machine running on Fedora so the script can run successfully before throwing the FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory .

like image 451
Ray Kim Avatar asked Jun 01 '18 22:06

Ray Kim


People also ask

How to solve Out of memory issue?

OutOfMemoryError: Java heap space. 1) An easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options "-Xmx512M", this will immediately solve your OutOfMemoryError.

How do I fix reached heap limit allocation failed JavaScript Heap out of memory?

To fix JavaScript heap out of memory error, you need to add the --max-old-space-size option when running your npm command. Alternatively, you can also set the memory limit for your entire environment using a configuration file.

What is out of memory error?

An "Out of Memory" error can occur when a Database Node Memory (KB) becomes less than 2 percent of the target size, and it cannot discard database pages on the node anymore to get free pages.


1 Answers

The solution for me was to set GENERATE_SOURCEMAP=false in the .env.production file as described here.

A better solution (although more time consuming) is code split the huge files ( >1MB)

like image 108
Ray Kim Avatar answered Oct 13 '22 19:10

Ray Kim