Repository navigation
Closed
Description
Bug Report or Feature Request (mark with an x)
- [X ] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.0.0
node: 7.7.4
os: win32 x64
@angular/animations: 4.0.0
@angular/common: 4.0.0
@angular/compiler: 4.0.0
@angular/core: 4.0.0
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 4.0.0
@angular/http: 4.0.0
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 4.0.0
@angular/platform-browser-dynamic: 4.0.0
@angular/router: 4.0.0
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.0
Repro steps.
ng build --prod --aot
The log given by the failure.
/node_modules/@angular/material/aut 92% chunk asset optimization
<--- Last few GCs --->
[6328:0000016AB4D09F00] 1775597 ms: Mark-sweep 1411.2 (1513.5) -> 1411.0 (1513.5) MB, 1240.6 / 0.0 ms last resort
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0000034B0DD266A1 <JS Object>
2: optimize [0000000FABC02311 <undefined>:5480] [pc=00000082575652C8](this=000000633199A279 <an AST_Call with map 0000014753FA0291>,compressor=00000226DBDECA61 <a Compressor with map 0000032B1EC8F829>)
3: before [0000000FABC02311 <undefined>:5463] [pc=0000008258C1818D](this=00000226DBDECA61 <a Compressor with map 0000032B1EC8F829>,node=000000633199A279 <an AST_Call with map 0000014753...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Desired functionality.
I would like to be able the app using AOT.
Mention any other details that might be useful.
I have tried changing ng.cmd to this:
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" --max_old_space_size=8192 "%~dp0\..\@angular\cli\bin\ng" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=8192 "%~dp0\..\@angular\cli\bin\ng" %*
)
and ngc.cmd to:
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" --max_old_space_size=8192 "%~dp0\..\@angular\compiler-cli\src\main.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=8192 "%~dp0\..\@angular\compiler-cli\src\main.js" %*
)
I have 8GB swap file. The build fails after 20-25 minutes standing on 92% progress.
Reacted by iuristona, GQ, Chris Nicola, Fabien Dehopré, Herc, Bart Slootweg, Veselina Radeva, Jason Hodges, Robin Regmi, Ahmad Baktash Hayeri and 148 more
Reacted by doomy [archive], Tal Koren, Cristi Anichitei, Gregory Petrosyan, Vlad Dobrescu, Jorge Y. C. Rodriguez, 浩然, Vijay Singh, andrea-spotsoftware, Alessandro Avila and 3 more
Reacted by Vijay Singh, Adrian Moisa and Maxime
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.