You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AOT build fails due to "JavaScript heap out of memory" #5618
Reacted by Teoman Tuncer, felikf, Eddie Oosthuizen, LosD, Lucas H., Ennio Bozzetti, Nikola Andreev, Mario Mol, Sean G. Wright, Jan Papenbrock and 3 more
i could run with optimizejs using node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build --release --prod --minifyjs --minifycss --optimizejs
For people who missed @dakotamurphyucf like I did:
using increase-memory-limit package after running npm install will reduce all need to know where binary files are and will do it for all the files - which in my case is very useful since I'm running both regular build and cordova build.
I'm using it only in my CI build script since locally it runs well.
basically: npm install increase-memory-limit -g
And run the command increase-memory-limit.
Pain is gone! No more suffering (for me at least)...
@jatinderkumargupta Please note that it's not enough to install increase-memory-limit, you need to run it also after npm installation of all packages has completed. I'm using windows and it worked for me.
Add it to package.json under the 'scripts' section not angular.json.
If you are facing the issue with your Azure DevOps build you can then call this new script command that you just added from your AzureDevops build task.
This thread was opened a while ago, and over time new memory problems have arisen and been solved. Meanwhile a lot of reports still appear here as comments.
Having all the feedback in a single thread makes it hard to get meaningful reports, or to inform people of what versions the regressions that affect them were fixed.
At the time of writing, there are 450 hidden comments:
Having so many hidden comments makes it hard for people to find information in anything but the latest comments. But on the other hand I don't think most people would go through all of the comments anyway. New users that see this thread mostly read the first and latest comments and lose things said in between.
So for the reasons stated above (high volume of comments, hidden comments, hard to report and inform people) I'm also locking this issue to prevent this comment from being lost as new comments come in.
Thank you to everyone that reported and helped diagnose these memory problems. If you encounter any new ones, please open a new issue so we can give that specific regression our full attention and provide a resolution for it.
So I'd like to leave the last comment in this thread as reiterating what I said in #5618 (comment), as I think that is what will help most people that find this issue:
Increasing the memory limit is not a hack, and something you should expect to do at some point. Node processes have a default memory limit of about 1.7gigs. When a node process starts getting close to the memory limit it needs to spend more and more time doing garbage collection to free up memory, which in turn makes it run more slowly.
Bigger projects will use up more memory than smaller projects so at some point a project will hit the memory limit. I personally use a npm script for this:
When you use have that script, you can use npm run ng-high-memory -- followed by the arguments instead of ng inside that project. Always use the double dash before arguments, otherwise they might not be parsed correctly.
Activity
filipesilva commentedon Mar 24, 2017
This is similar to #1652, but seems localized to AOT compilations. There might be improvements we can do to help.
iuristona commentedon Mar 24, 2017
I got the same issue too.
So, I tried to build the same project (@angular 4.0.0) using ng-cli 1.0.0-rc.4 and it works fine.
ng build --prod --aot
@angular/cli: 1.0.0-rc.4
node: 6.9.5
os: win32 x64
@angular/common: 4.0.0
@angular/compiler: 4.0.0
@angular/core: 4.0.0
@angular/forms: 4.0.0
@angular/http: 4.0.0
@angular/platform-browser: 4.0.0
@angular/platform-browser-dynamic: 4.0.0
@angular/router: 4.0.0
@angular/cli: 1.0.0-rc.4
@angular/compiler-cli: 4.0.0
tonny008 commentedon Mar 27, 2017
I have the same issue. my project works on cli rc.4. it fails when ng build --prod after update to 1.0.0.
aminebizid commentedon Mar 27, 2017
I'm so afraid there will be no solution for this issue.
I reverted to rc.2 because of this :(
efstathiosntonas commentedon Mar 28, 2017
In my case, I installed typescript@2.1.6 instead of @~2.2.0 and the memory issue went away. Give it a try.
There is an issue in ~2.2.0 and @angular/language-service 4.0.0 (in my case i use it)
AngelVlc commentedon Mar 28, 2017
I've changed max_old_space_size in %AppData%\npm (Windows) and it works for me when launching ng serve with 1.0.0.
aminebizid commentedon Mar 28, 2017
@efstahiosntonas are you using ng4?
efstathiosntonas commentedon Mar 28, 2017
@Zigzag95 yes, ng4
elvisbegovic commentedon Mar 28, 2017
same problem here
chrisnicola commentedon Mar 28, 2017
I'm getting OOM errors with
@ngtools/webpack1.3.0 and@angular4.0.0. This is on OSX and not Windows as well.427 remaining items
ImranAhmed commentedon Oct 21, 2018
I started seeing this on my Azure DevOps Build server after upgrading to Angular 7.
Adding the following to
package.jsonand then calling this from my build task fixed it."build-prod": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --prodsanidz commentedon Nov 16, 2018
If you have this problem with quagga js library , pay attention that "@angular/service-worker" is installed before "quagga": "^0.12.1" package.
mariohmol commentedon Nov 19, 2018
i could run with optimizejs using
node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build --release --prod --minifyjs --minifycss --optimizejsHarelM commentedon Dec 3, 2018
For people who missed @dakotamurphyucf like I did:
using
increase-memory-limitpackage after running npm install will reduce all need to know where binary files are and will do it for all the files - which in my case is very useful since I'm running both regular build and cordova build.I'm using it only in my CI build script since locally it runs well.
basically:
npm install increase-memory-limit -gAnd run the command
increase-memory-limit.Pain is gone! No more suffering (for me at least)...
marcj commentedon Dec 6, 2018
Or just use
export NODE_OPTIONS=--max_old_space_size=4096which should fix it as well.jatinderkumargupta commentedon Dec 10, 2018
@marcj this solution worked for me.
I set NODE_OPTIONS for windows with following command:
set NODE_OPTIONS=--max_old_space_size=4096Installing increase-memory-limit, did not work for me on windows. I have not tried on linux/ubuntu or other OS.
HarelM commentedon Dec 10, 2018
@jatinderkumargupta Please note that it's not enough to install
increase-memory-limit, you need to run it also after npm installation of all packages has completed. I'm using windows and it worked for me.jatinderkumargupta commentedon Dec 10, 2018
Thanks @HarelM, I run that like you mentioned, but it did not work for me. May be some other problem then.
pdemro commentedon Dec 20, 2018
In Azure Devops I added a command line task which executes the command below prior to the ng build:
node --max-old-space-size=8192
This seems to have resolved the issue for now..
bkarv commentedon Dec 23, 2018
@ImranAhmed thanks for the suggestion. However where abouts do you add it in angular.json? If I add it I get an 'Property build-prod' not allowed?
ImranAhmed commentedon Dec 23, 2018
@bkarv
Add it to package.json under the 'scripts' section not angular.json.
If you are facing the issue with your Azure DevOps build you can then call this new script command that you just added from your AzureDevops build task.
bkarv commentedon Dec 23, 2018
I tried scripts but got errors. I ended up following the suggestion to export NODE_OPTIONS in OS and it worked. Many thanks
filipesilva commentedon Dec 27, 2018
Hi all,
This thread was opened a while ago, and over time new memory problems have arisen and been solved. Meanwhile a lot of reports still appear here as comments.
Having all the feedback in a single thread makes it hard to get meaningful reports, or to inform people of what versions the regressions that affect them were fixed.
At the time of writing, there are 450 hidden comments:
Having so many hidden comments makes it hard for people to find information in anything but the latest comments. But on the other hand I don't think most people would go through all of the comments anyway. New users that see this thread mostly read the first and latest comments and lose things said in between.
So for the reasons stated above (high volume of comments, hidden comments, hard to report and inform people) I'm also locking this issue to prevent this comment from being lost as new comments come in.
Thank you to everyone that reported and helped diagnose these memory problems. If you encounter any new ones, please open a new issue so we can give that specific regression our full attention and provide a resolution for it.
So I'd like to leave the last comment in this thread as reiterating what I said in #5618 (comment), as I think that is what will help most people that find this issue:
Increasing the memory limit is not a hack, and something you should expect to do at some point. Node processes have a default memory limit of about 1.7gigs. When a node process starts getting close to the memory limit it needs to spend more and more time doing garbage collection to free up memory, which in turn makes it run more slowly.
Bigger projects will use up more memory than smaller projects so at some point a project will hit the memory limit. I personally use a npm script for this:
npm scripts scripts go into the
package.jsonfile, under thescriptskey:When you use have that script, you can use
npm run ng-high-memory --followed by the arguments instead ofnginside that project. Always use the double dash before arguments, otherwise they might not be parsed correctly.