Issue
I am getting error "Javascript | Heap out of memory" exeption when running our build in jenkins. We had similar issue in local and by setting node --max-old-space-size=8192 we have solved the issue. How do we get rid of the same on the server side?
Solution
If you are using Package.json file than try below. May be it will solve your problem.
"scripts": { "start": "node --max-old-space-size=8192 app.js , }
You have to change other option in "start" as per your need.
For example, you can use your own file instead of app.js, or you can also just set command like below without any file name.
"scripts": { "start": "node --max-old-space-size=8192, }
If any help needed, tell me.
--max-old-space-size is use for set "old space" memory limit, means garbage collection or heap where all javascript objects are available.
So for solve the issue of memory you have to exceeds the limit of memory.
For example, if your server machien have 2 GB of memory, than you can set --max-old-space-size to around 1.5 GB, so other memory is available to perform other tasks.
You can also use below option if you are using node js application.
https://www.npmjs.com/package/increase-memory-limit
Answered By - Kaushik Andani
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)