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
I have the same problem when running "ng build -w"
@angular/cli: 1.0.0
node: 7.8.0
@angular/* 4.0.2
setting --max_old_space_size=8192 works for me, but it is not really a good solution since I cannot redistribute it with the source code to my developers.
One note though, there are both a ng.cmd and an ng file (the latter one is an sh file), and if you are in windows as we are both can be used depending on if you run ng from git bash or cmd so both needs to be changed.
My solution to the problem will probably be to change the npm build command from ng build to call a copy of the ng bash file which I distribute with my code.
@omeralper: This is my solution, it requires people to use git bash as terminal if on windows, but it would be easy to change if needed (just use the cmd file instead):
In my project root I have a folder called scripts and in it a file called ng.sh, which is a copy from node_modules/.bin/ng but with more allowed RAM to be used
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" --max_old_space_size=8192 "./node_modules/@angular/cli/bin/ng" "$@"
ret=$?
else
node --max_old_space_size=8192 "./node_modules/@angular/cli/bin/ng" "$@"
ret=$?
fi
exit $ret
We also hit that issue in NativeScript when using the @ngtools/webpack plugin with nativescript-dev-webpack. We use tsconfig paths for mapping our tns-core-modules. They look like that:
However, the bundling fails with the mentioned error (JavaScript heap out of memory). Just like @zackschuster , as a workaround we specified each path mapping manually:
@sis0k0 what do your recompile times look like with that setup? i was getting 40-50s recompiles (on an absurdly tiny project) until i dropped the path maps, at which point it dropped to ~2s.
I am using @angular/cli 1.0.0-rc.4, if I upgrade to 1.0.0 it gives me the error of
angular cli FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Work Around Fix
I was able to fix the issue by changing my ng.cmd file to @IF EXIST "%~dp0\node.exe" ( "%~dp0\node.exe" --max_old_space_size=8192 "%~dp0\node_modules\@angular\cli\bin\ng" %* ) ELSE ( @SETLOCAL @SET PATHEXT=%PATHEXT:;.JS;=;% node --max_old_space_size=8192 "%~dp0\node_modules\@angular\cli\bin\ng" %* )
@hansl@filipesilva I am not able to upgrade my application to angular/cli 1.0.0, since I am at angular/cli 1.0.0.rc-4, don't want to make the jump to the latest version without testing my components
Have been affected by this issue since @angular/cli 1.0 was released
But currently we are able to workaround it by running
ng build --aot --sourcemaps=false --environment=prod
It's not exactly the same as the --prod parameter but at least it works.
@filipesilva This is pretty serious and the workaround does not allways work - it seems to affect all medium/large projects. Needs solved for angular + angularcli to remain a viable technology for serious web projects.
OOM on CI machine ( also after adding --max-old-space-size=4096 to node ) due to broken symlink
After fixing it:
ng build --prod
ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' @ ./src/main.ts 3:0-74 @ multi ./src/main.ts
`
Upgraded @angular/cli to 1.2.4, still getting the same error ( yarn )
After looking at #7125 it looked like it was an aot related, package dependency issue.
Reverting back to npm fixed it.
i've also seen this error pop up when using @ngtools/webpack by itself. interestingly, it doesn't happen until after a few rebuilds, implying there's a huge memory leak somewhere in either webpack (doubtful) or the ngtools plugin.
Exact same error here, but with @ngtools/webpack
I've tried running it with Node LTS 6.11.2 and Node Latest as well 8.2.1
Tried with Typescript 2.3.2 and 2.4.2.
All my angular packages are at 4.3.3
AoT is pretty much necessary for large apps, so it's kinda ironic we can't get it so build for those.
Just as a heads up. It turns out when I use YARN instead of NPM to RESTORE packages ng build completes successfully.
I am using
ng build --env=prod --aot
When I restore packages using npm install -- same error from this issue (out of memory)
When I restore packages using yarn install -- no error - success
I've also been getting the out of memory issue when running ng serve. It works fine for hours, but if I've been developing for a while (I've seen it anywhere from 2-5 hours) I will get the out of memory crash. When rerunning the serve command, I can go typically for another 2-5 hours. The first time I saw this was when updating to a beta version of 1.3, but I haven't seen an improvement with the current release.
For me it also happens with the normal "ng serve" after upgrading to 1.3 version, every time the project recompiles, its takes more time than the previous (6s, 10s, 30s, 60s) and after 4 or 5 times, it goes out of memory.
This problem is happening as well for our project. Can't build aot on build server with the same javascript heap out of memory. We are also using the experimental webpack 3 support.
For us - building locally with ng build --target=production --environment=prod --base-href /myproject/ --aot --build-optimizer
works just fine, but when we build it on our server, we get the FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
error. However, if we remove the --build-optimizer everything runs fine.
I've tried adding the increase-memory-limit library, but without any luck.
We seem to face the error even on allocating 12GB of memory for the build.
Is there any way to debug what is causing the memory leak? also, could this be solved by implementing lazy loading of modules, since this is during build time?
Commands used:
1.node --max_old_space_size=12000 ./node_modules/@angular/cli/bin/ng build --prod --aot --env=prod
2. updated the ng to accept the --max_old_space_size parameter
The build is working only with --sourcemap=false and --aot=false; but this is causing memory leaks and page load issues in the browser due to huge application size.
I don't know if it can help someone but we had the same problem after upgrading to version 1.3.0. And we had others problem too : slow compilation and bad names for generated chunk.
Still a problem for us even after CLI upgrade to 1.3.1 and @angular upgrade to 4.3.5
tried typescript 2.5 but run into some compilation problems. we're on 2.4.2.
edited:
On our local machines or our gitlab runner instances we can't reproduce the problem. For some reason the build only fails on our jenkins box. The only difference I've been able to gather is jenkins is on a slightly older version of node/npm version:
v6.9.1
3.10.8
instead of
v6.11.0
3.10.10
fixed by changing our production npm build script to:
No amount of setting max-old-space-size helped on our project. However, as we only build AOT in prod, we have temporarily disabled sourcemaps which seemed to fix it for us on our CI server.
Like @mattem I have not been able to get the max-old-space-size to work either. I do not if I am fully setting it up right though since the build process I have uses webpack with "ngtools/webpack".
I know, and trust me, I'm just as much struggling with this. Not fun when the build server starts to run out of memory. It's a serious problem that should be addressed. This workaround just helped me to limp along a little farther, just like turning off the source maps. Your mileage may vary.
On my computer I was limiting to 8Gb and the ng build was working fine.
(with old-max-space-size)
But now I've got a big big project and believe me, out of memory.
I have a code generator that builds everything perfectly.
but the new project has more than 200 entities.
The creation of modules and lazy loading depends on the settings made by the client and their entities.
I would not want to separate in several applications because there is a lot of dependency.
(200 services, 600 components)
The project runs fine with ng serve, but not with ng build.
I rented a virtual machine with 28Gb ram and believe me, did the build using 27Gb of RAM.
The service node occupied exactly 27Gb.
(I put the limit of 28gb)
Everything works fine with ng serve.
can anyone know to tell me if just separating into several lazy loading modules it will need less memory to compile with ng build? or it works only to separate the JS?
I can not rent a virtual machine whenever I need to run ng build.
And the effort of change will be very high.
So I needed to be sure of what to do.
@tolitech Instead of depending on having enough RAM for this to build, just add swap to your machine. The build will be a little slower, but you don't need to be renting machines with 28 GB of RAM.
I too want this to be resolved ASAP, but adding swap space gets around the memory issue.
@joecot Thank you.
I'll try to do this and see if it works.
If it works, I do not see any problems if it takes 8 hours.
I leave a night job for publication without problems.
@joecot @notsonotso
It worked.
I configured 32Gb virtual memory (swap), --max_old_space_size and finally worked.
It used the 28gb (It's too high), but it worked.
Thank you very much for the idea, @joecot
@mhevery@bradlygreen - apologies for pulling you into this one, but with @tolitech's extreme case above, the value proposition of Angular is starting to become seriously undermined.
Our codebase is growing rapidly, and our team is continuously running into these memory issues, where we even reach the limitations of our development and build machines. In all my years of web development there's never been a case that I would run out of the capabilities of the machine, just to compile to several 300k files for my webapp/website. It seems to be a memory optimization or architectural issue that hopefully can be avoided.
We've already lost countless hours on these problems, and the premise that Angular is a framework that scales for large enterprise applications doesn't hold up anymore.
I'd really appreciate if this issue could be prioritized, as I'm really starting to doubt whether our choice of Angular as a suitable framework was correct, considering that only the AOT builds are performant and small enough to ship to customers over the wire, and that we're struggling to get those to work. Thank you.
@bgever Apparently google is not using angular-cli/webpack themselves, so they don't run into problems like this. I suspect this is why this problem receives so little attention from the angular developers. If this continues, the community should be publicly warned about angular being unsuitable for large projects.
You were perfect in your words, @bgever .
I'm already thinking that Angular does not work for large applications, after all I'm now needing 28 Gb of RAM and the project could grow bigger. (This is the first day of this application).
I'm already thinking about another strategy for this type of project, maybe even change technology because I'm realizing that this problem is occurring with many people and for a long time.
I believe my customer will not accept me saying that he needs 28 Gb RAM to compile his own project.
I'm very worried about this.
Same here. Running Angular CLI 1.3.2 and Angular 4.3.6. Added this based on another thread to get it to work. My app isn't very big but CLI clocked in at 4GB to build my app.
@bjornharvold@tolitech We need 1024go ram 32ghz cpu, so 32'000'000'000 calcul per second to build angular but if you learn bazel from google it can be faster 😂
This worked for me, add to package.json scripts section. Watching the memory usage in task manager it got up to around 4gb usage. Seems a touch excessive!
@filipesilva Is there any news regarding to this issue?
I'm curious why a semi-large project needs more than 2 gigs to build. I am not familiar with the inner workings of the compilation process, but it seems rather high to me.
EDIT:
using the --build-optimizer flag causes the issue, it was working fine, but I recently upgraded the cli and I see that it uses a newer build-optimizer (0.0.31), maybe memory leak on the optimizer?
Also hit this memory issue. Can be 'resolved' by using the build script node --max-old-space-size=4096 ./node_modules/@angular/cli/bin/ng build --prod but hopefully this bug will be fixed soon. Why does it need over 2GB of memory?!
Hey all, I'm seeing a lot of new reports of this happening after 1.5 is out. One of the changes we did for 1.5 was to use Build Optimizer by default on Angular version 5 projects. Build optimizer does indeed use a lot of memory (angular/devkit#240).
Can you tell me if turning off build optimizer helps with your memory crashes? You can do it with --build-optimizer=false. Turning off sourcemaps can also help via --sourcemaps=false.
If these options don't help, can you post here the full failure log please, including command run?
With @angular: 4.4.6 ; @angular/cli: 1.4.9 I can get a --prod build with --max_old_space_size=6144 but with @angular: 5.0.0 ; @angular/cli: 1.5.0 I run out of memory even with --max_old_space_size=8192. I can get a build with --max_old_space_size=10240, but my CI does not support that configuration.
@filipesilva, @hansl, Before anything, thanks so much for this project- Angular has been great for our team. We love the framework and we love the CLI so thanks for all your hard work.
This memory issue seems like it is becoming a real problem. I'm looking for some messaging from the Angular team around expectations here, and I'd be happy to give whatever data is necessary to help move it forward.
Our team is an enterprise team with a medium-large app. We ran into this memory issue a while back, and upped the max_old_space_size to 1GB and then later 2GB. Each time it solved our problem for a few months. But as the app continues to grow we've run into it again now and we can't do this forever. Our toolchain uses Bitbucket pipelines, which like many other CI's maxes out available memory (3GB is our max given our other needs), so we're beginning to run up against a wall.
I've been taking some benchmarks with our app, it looks like you're correct in your post above: 1.5.0, with --build-optimizer=false uses equivalent memory to 1.4.5.
Our app has ~180 components and ~30 services across ~22 modules. I'd like to think it is constructed in a reasonably smart manner, following best practices and general clean code design. The build --aot --build-optimizer=false --sourcemaps=false for this project using 1.5.0 now takes about 2925 GB of memory.
Two general questions for you and others, about (1) expectations and (2) short-term alleviation:
(1) Is Angular built for enterprise development? If so, this issue seems to be of the highest priority and the community deserves more frequent and clear messaging on this. If not, your users need to know this because lots of decisions across hundreds of companies ride on that.
(2) Are there any recommendations from the Angular team about ways to alleviate this issue?
Should we split out our modules into "pre-compiled" libraries?
Is memory usage particularly worse for high Component counts, high Service counts, etc?
Other flags that help trade memory for build-time?
Again, I'd be happy to test any theories/provide data about our large application to help get to the bottom of this, and again, thanks for all the hard work you've done on this.
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
We have not tried the hacks above on changing the old space memory... our application isn't apparently as big as some of the others on this thread, but yet fails on cli 1.5.0.
@filipesilva: --build-optimizer=false and --sourcemaps=false works for me with cli 1.5.
Without them, I was getting "JavaScript heap out of memory".
Thanks for your help!
[12192:00000000004C39A0] 236834 ms: Mark-sweep 1420.3 (2200.9) -> 1420.3 (2159.4) MB, 578.6 / 0.0 ms last resort GC in old space requested
[12192:00000000004C39A0] 237461 ms: Mark-sweep 1420.3 (2159.4) -> 1420.3 (2136.9) MB, 627.2 / 0.0 ms last resort GC in old space requested
@swftvsn, memory is cheap if you have control over it, but we deploy to a Docker swarm, and containers have limited memory. This is a pretty serious issue for us. I'd prefer a slower build if that means caching stuff to disk and not running out of memory.
I am getting this issue after upgrading to cli 1.5 and angular 5.0.
I want to highlight the question above:
Is Angular built for enterprise development?
I am so confused why any compiler would need 4 gigs of memory to compile a web app..... To get it to compile aot post upgrade I had to jack the memory up to 4 gigs. Our app has 2 feature module libraries each with about 15 modules, ~60 modules in the main app, and ~15 services. We have a lot left to build as well.
I would imagine it has to do with the obscene amount of dependencies + all the hoops that are done to statistically analyze all the dependencies and your code in order to shake the trees. Take a look at node_modules if you dare. (And source / debug maps and things I don't even know about)
Excessive memory consumption is usually caused by a lot of data and/or abstraction over abstraction over abstraction over... :) Or a bug.
For now I'm happy and I just feed the beast. I do hope it looses some of it's appetite in the coming versions though..
I'm less concerned about "how could this possibly...?" than I am about the lack of communication.
The compilation itself is doing some pretty heavy lifting right now. It's really great actually. The entire CLI is. It bundles this thing up and serves it pretty compactly. In fact his may be a testament to just how easy Angular makes it to build large scale web apps... their size is outpacing the toolchain.
I'm just looking for the Angular team to set expectations here, that's all:
Does the Angular team consider this a problem? (its been tagged as "required" since March)
Is there any action being taken to fix it? (its been tagged as "investigation" since March)
Is this a fixable issue in the next month? 6 months? year?
If it's not a fixable issue, are there any other build configurations/toolchains they'd recommend?
Are they still researching the answers to the above questions?
Any answer to those questions is okay... but it's important that those answers (and their progress) are communicated to the community in an iterative fashion. My team and many other teams need to make decisions based off those answers, and right now we feel frozen.
This is an open source project that we're all getting for free. It's added tremendous value already even with this issue; so some people are being awfully critical given this. At the same time, open communication is integral to the success of solid open source projects: we're looking to the Angular team for that leadership.
Recent upgrade our project to Angular 5 and Angular CLI 1.5.
We have 100+ components and 20+ modules. The build --prod is taking forever and finally throw heap out of memory exception which is very frustrating!
As I mentioned here a few months ago, I have a very large project with several modules too, +120 pages, +500 components (pages are divided into at least 3 components like grid, form).
To get ng build -prod to work I had to test on a machine with 32 Gb of RAM, nodeJS consumed 28 Gb to compile the project. Impressive.
The solution was actually put 32 Gb as virtual memory on the machine (swap).
In addition, of the already known "--max_old_space_size".
@swftvsn I am still not getting it. Maybe it is because I come from .NET where the c# compiler would tear through a project with comparable amounts of classes without breaking a sweat.
@tolitech This is exactly the main point. If we need machines with 32 GB of ram to build the project, some cloud agents won't be able to handle this/aren't configurable to upgrade the hardware. Thus, we would need to make architectural decisions to start building segmented SPAs to keep the size of a project down, catering to compiler limitations.
@dpxxdp While I do agree that it is great that it is free and open source (thanks as well team!), I don't feel that it is a criticism to report a major bug/functional limitation that requires a hardware upgrade as a work around. I don't think anyone is trying to criticize the work that was done, but rather increase the priority on this issue.
use custom build with webpack
currently default build use several optimization step + minification.
use command like ng build --app app -aot=true -e=prod -sm=false -ec=true --named-chunks=false -oh=all -pr=false
this will generate bundles without minification and general size for vendor bundle will increased in my case for 8%. Build time decreased for twice, but minification step take long time 6-7 min in CI machine (2gb). I use gulp for post build actions in my case its uglify js and postcss.
My app
~72 services (CRUD operation + some general logic)
~10 pipe
~15 directive
~170 components
~ 80 model class (data from API)
~ 15 module
as for me i want some flags to set optimization step count, tree shake deep (function, class, variable)
I've bumped the priority on this issue and will be working on it. We didn't consider it to be as urgent before because the solution at the time was to increase the available memory to node, which defaults to 1.7gb. So it was expected that at some point projects would need more memory than the default.
However with the release of 1.5 the memory requirements seem to have increased dramatically. Projects that didn't have any memory problems before now do. 32gb is definitely a ridiculous amount of RAM and shouldn't be needed.
At this point I'm not sure what caused the memory spike but have a few hypothesis. With CLI1.5 + Angular 5 we use a new pipeline that does better type checking by using a full TS program. Maybe there's a bad cache somewhere in there, or the TS program is taking a lot of memory. Another possibility is Uglify, which we had to upgrade as well. Or it might be something in the AOT compiler itself. We also default build optimizer to true now and it's not really optimized for neither speed nor memory.
If you're running into this problem and have time, I'd appreciate if you could answer a couple questions:
What version of the CLI and Angular are you on?
Does this only happen on ng build --prod?
Do you still get the memory error with these build commands:
ng build --prod --build-optimizer=false
ng build --aot
ng build --aot --build-optimizer
If you have a project that I can look at, can you link it please?
What version of the CLI and Angular are you on?
1.5.0 angular 5.0.1
Does this only happen on ng build --prod?
yes
Do you still get the memory error with these build commands: ng build --build-optimizer=false no ng build --aot no ng build --aot --build-optimizer no
@filipesilva
Windows 7 Pro 64-bit
12 Gigs of ram
CLI 1.5.0, Angular 5.0.0
Project details:
~120 components
15 modules
Do you still get the memory error with these build commands:
ng build --prod: yes
ng build --build-optimizer=false: no
ng build --aot: no
ng build --aot --build-optimizer: yes
ng build --prod: fail ng build --prod --build-optimizer=false: fail ng build --prod --build-optimizer=false --sourcemaps=false: fail ng build --prod --aot=false: works ng build: works ng build --aot=true: works ng build --aot=true --build-optimizer=true: fail
What version of the CLI and Angular are you on? @angular/cli@1.5.0 , @angular 5.0
Does this only happen on ng build --prod? yes
Do you still get the memory error with these build commands: ng build --build-optimizer=false : NO ng build --aot : NO ng build --aot --build-optimizer: NO
The versions I am using
CLI - 1.2.0 and Angular 4.2.5
Modules: ~ 130
Components: ~ 200
Services: ~ 70
getting the build issues with below options.
ng build --prod: fail
ng build --aot=true: fail
ng build --aot=true --sourcemaps=false : Works most of the times and very often it is failing.
ng build --prod --aot=false : works
I had experienced the issue FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory with ng build --prod. I have solved the problem by using
node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod
Same issue. Upgraded to A5. ng build --prod results in out of memory error below. The error does not occur without --prod. Increasing the --max_old_space_size is not really the answer, something is fundamentally wrong and has stopped our A5 upgrade going anywhere.
In my project everything was working fine in --prod --aot mode up until a day ago when I decided to migrate to HttpClient to prepare for the Angular 5 / CLI 1.5 switch. No version changes, no CLI changes were involved.
I upgraded my services and moved some error/auth logic to a couple of interceptors. My vendor dev bundle went from 15MB to 6MB and I was all impressed. Then I decided to sanity check my prod aot build with ng serve --prod --aot and I started getting the OOME.
Any update on this? This issue was raised back in March and is now manifesting itself in Angular 5 (and 4) prod builds. Seems somehow to be related to HttpClient.
Please can you investigate as a priority as we can not go to production using Angular 5, which is currently not fit for purpose.
Activity
marcalj commentedon Apr 3, 2017
Same problem here with:
@angular/cli: 1.0.0-rc.2
node: 6.9.2
os: darwin x64
@angular/common: 2.4.10
@angular/compiler: 2.4.10
@angular/core: 2.4.10
@angular/forms: 2.4.10
@angular/http: 2.4.10
@angular/platform-browser: 2.4.10
@angular/platform-browser-dynamic: 2.4.10
@angular/router: 3.4.10
@angular/cli: 1.0.0-rc.2
@angular/compiler-cli: 2.4.10
Ristaaf commentedon Apr 19, 2017
I have the same problem when running "ng build -w"
@angular/cli: 1.0.0
node: 7.8.0
@angular/* 4.0.2
setting --max_old_space_size=8192 works for me, but it is not really a good solution since I cannot redistribute it with the source code to my developers.
One note though, there are both a ng.cmd and an ng file (the latter one is an sh file), and if you are in windows as we are both can be used depending on if you run ng from git bash or cmd so both needs to be changed.
My solution to the problem will probably be to change the npm build command from ng build to call a copy of the ng bash file which I distribute with my code.
omeralper commentedon Apr 19, 2017
@Ristaaf How did you change the ng file? Where did you add --max_old_space_size in this file? Can you please share your file.
Ristaaf commentedon Apr 21, 2017
@omeralper: This is my solution, it requires people to use git bash as terminal if on windows, but it would be easy to change if needed (just use the cmd file instead):
In my project root I have a folder called scripts and in it a file called ng.sh, which is a copy from node_modules/.bin/ng but with more allowed RAM to be used
Then in my package.json I do:
KeithGillette commentedon May 4, 2017
I am experiencing a similar issue resulting in a
JavaScript heap out of memoryerror when callingng e2ein a project using:@angular/cli@1.0.1@angular/*@4.1.0node@6.10.2I was able to create a cross-platform work-around by changing the
package.jsone2escript entry to:speedy32 commentedon May 26, 2017
On windows
@if EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" --max_old_space_size=4096 "%~dp0\node_modules@angular\cli\bin\ng" %*
) ELSE (
@SETLOCAL
@set PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=4096 "%~dp0\node_modules@angular\cli\bin\ng" %*
)
dakotamurphyucf commentedon May 28, 2017
check this npm package out https://github.com/endel/increase-memory-limit
isaacplmann commentedon Jun 1, 2017
I wrote a little script that lets me control the memory limit in the config section of
package.json.https://github.com/isaacplmann/angular-cli-alias
increase-memory-limitlooks pretty sweet too. It didn't exist when I wrote my script and it doesn't let you set your own memory limit.zackschuster commentedon Jun 1, 2017
i've been able to repro this with a minimal test case using an out-of-the-box cli app; relevant file here.
basically it seems like trying to match a wildcard without specifiers will blow up the app, which is weird since the test case is pulled almost directly from typescript documentation.
note that
"*": ["*"]does not crash the app, only"*": ["*", "$dir/*"]as a workaround, i've manually specified each of my path maps, which is annoying but lets me compile:
sis0k0 commentedon Jun 6, 2017
We also hit that issue in NativeScript when using the
@ngtools/webpackplugin withnativescript-dev-webpack. We use tsconfig paths for mapping our tns-core-modules. They look like that:However, the bundling fails with the mentioned error (JavaScript heap out of memory). Just like @zackschuster , as a workaround we specified each path mapping manually:
zackschuster commentedon Jun 6, 2017
@sis0k0 what do your recompile times look like with that setup? i was getting 40-50s recompiles (on an absurdly tiny project) until i dropped the path maps, at which point it dropped to ~2s.
aminebizid commentedon Jun 6, 2017
@zackschuster
What do you mean by path maps?
zackschuster commentedon Jun 6, 2017
@Zigzag95
sis0k0 commentedon Jun 6, 2017
@zackschuster, similar times.
tgrosh commentedon Jun 15, 2017
#5618 (comment)
I tried the increase-memory-limit package, and I still get Javascript heap out of memory
elvisbegovic commentedon Jul 9, 2017
It's time to fix this !!! In real big project angular is bad because of that ! Maybe webpack problem !! Thanks
cassmtnr commentedon Jul 10, 2017
Still nothing on this?
I am using @angular/cli 1.0.0-rc.4, if I upgrade to 1.0.0 it gives me the error of
angular cli FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
aminebizid commentedon Jul 10, 2017
Now we understand why Google don't use webpack with ng for its apps
cimachris commentedon Jul 13, 2017
Work Around Fix
I was able to fix the issue by changing my ng.cmd file to
@IF EXIST "%~dp0\node.exe" ( "%~dp0\node.exe" --max_old_space_size=8192 "%~dp0\node_modules\@angular\cli\bin\ng" %* ) ELSE ( @SETLOCAL @SET PATHEXT=%PATHEXT:;.JS;=;% node --max_old_space_size=8192 "%~dp0\node_modules\@angular\cli\bin\ng" %* )Masquer commentedon Jul 13, 2017
@cimachris this is not exactly a fix but rather a workaround that can possibly postpone the problem
cimachris commentedon Jul 13, 2017
Is that better?
cassmtnr commentedon Jul 13, 2017
@hansl @filipesilva I am not able to upgrade my application to angular/cli 1.0.0, since I am at angular/cli 1.0.0.rc-4, don't want to make the jump to the latest version without testing my components
edmund-lee commentedon Jul 14, 2017
Have been affected by this issue since @angular/cli 1.0 was released
But currently we are able to workaround it by running
ng build --aot --sourcemaps=false --environment=prod
It's not exactly the same as the --prod parameter but at least it works.
xnnkmd commentedon Jul 14, 2017
ng e2e also results in a similar error:
xnnkmd commentedon Jul 14, 2017
@filipesilva This is pretty serious and the workaround does not allways work - it seems to affect all medium/large projects. Needs solved for angular + angularcli to remain a viable technology for serious web projects.
emazv72 commentedon Jul 26, 2017
@angular/cli: 1.2.3
node: 6.10.0
os: linux x64
@angular/animations: 4.3.1
@angular/common: 4.3.1
@angular/compiler: 4.3.1
@angular/core: 4.3.1
@angular/forms: 4.3.1
@angular/http: 4.3.1
@angular/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.2.3
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1
App with 3 modules and about 50 components, after switching @angular/cli from 1.1.x to 1.2.x
ng build -target=productionemazv72 commentedon Jul 26, 2017
root cause analysis:
After fixing it:
ng build --prod
ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' @ ./src/main.ts 3:0-74 @ multi ./src/main.ts`
Upgraded @angular/cli to 1.2.4, still getting the same error ( yarn )
After looking at #7125 it looked like it was an aot related, package dependency issue.
Reverting back to npm fixed it.
zackschuster commentedon Jul 26, 2017
i've also seen this error pop up when using
@ngtools/webpackby itself. interestingly, it doesn't happen until after a few rebuilds, implying there's a huge memory leak somewhere in either webpack (doubtful) or the ngtools plugin.RuedigerMoeller commentedon Aug 6, 2017
this is so java :))
baio commentedon Aug 8, 2017
Same issue. As soon as project gain size this thing happens.
etiennetalbot commentedon Aug 8, 2017
Exact same error here, but with
@ngtools/webpackI've tried running it with Node LTS
6.11.2and Node Latest as well8.2.1Tried with Typescript
2.3.2and2.4.2.All my angular packages are at
4.3.3AoT is pretty much necessary for large apps, so it's kinda ironic we can't get it so build for those.
amikitevich commentedon Aug 10, 2017
after update to angular/cli@1.3.0 have the same issue.
@angular/cli: 1.3.0
node: 8.2.1
os: darwin x64
@angular/animations: 4.3.3
@angular/common: 4.3.3
@angular/compiler: 4.3.3
@angular/core: 4.3.3
@angular/forms: 4.3.3
@angular/http: 4.3.3
@angular/platform-browser: 4.3.3
@angular/platform-browser-dynamic: 4.3.3
@angular/router: 4.3.3
@angular/cli: 1.3.0
@angular/compiler-cli: 4.3.3
command:
ng build -prod --build-optimizer --aot=true --progress=false --sourcemap
brunobertechini commentedon Aug 10, 2017
Just as a heads up. It turns out when I use YARN instead of NPM to RESTORE packages ng build completes successfully.
I am using
ng build --env=prod --aotWhen I restore packages using npm install -- same error from this issue (out of memory)
When I restore packages using yarn install -- no error - success
blyndcide commentedon Aug 10, 2017
Also got this error after updating to @angular/cli 1.3.0.
Problem solved after upgrading typescript both locally and globally to 2.4.2
wojciech-wator commentedon Aug 11, 2017
Also got this error.
Locking @ngtools/webpack to version 1.5.4 helps.
josephliccini commentedon Aug 11, 2017
I had to increase memory given to Node, as well as bump TS to 2.4.2, but after that I did get a successful build. looking forward to NG5 AoT compiler
williangd commentedon Aug 14, 2017
Same problem here after updating to @angular/cli 1.3.0.
ChenReuven commentedon Aug 15, 2017
@williangd also for me with 1.3.0
jloosli commentedon Aug 15, 2017
I've also been getting the out of memory issue when running
ng serve. It works fine for hours, but if I've been developing for a while (I've seen it anywhere from 2-5 hours) I will get the out of memory crash. When rerunning the serve command, I can go typically for another 2-5 hours. The first time I saw this was when updating to a beta version of 1.3, but I haven't seen an improvement with the current release.Dunos commentedon Aug 16, 2017
For me it also happens with the normal "ng serve" after upgrading to 1.3 version, every time the project recompiles, its takes more time than the previous (6s, 10s, 30s, 60s) and after 4 or 5 times, it goes out of memory.
AlekBro commentedon Aug 17, 2017
Same issue.
95% emitting
<--- Last few GCs --->
160332 ms: Mark-sweep 1346.8 (1439.3) -> 1346.7 (1439.3) MB, 648.6 / 0.0 ms [allocation failure] [scavenge might not succeed].
160934 ms: Mark-sweep 1346.7 (1439.3) -> 1346.8 (1439.3) MB, 602.0 / 0.0 ms [allocation failure] [scavenge might not succeed].
161564 ms: Mark-sweep 1346.8 (1439.3) -> 1346.8 (1423.3) MB, 629.5 / 0.0 ms [last resort gc].
162181 ms: Mark-sweep 1346.8 (1423.3) -> 1346.7 (1423.3) MB, 616.9 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0000009DB903FA99
1: DoJoin(aka DoJoin) [native array.js:~129] [pc=000000A40AE7FE82] (this=0000009DB9004241 ,w=00000355FBAF7F99 <JS Array[287]>,x=287,N=0000009DB9004281 ,J=0
000009DB904A369 <String[1]: >,I=00000342545B4E81 <JS Function ConvertToString (SharedFunctionInfo 0000009DB905DBC9)>)
2: Join(aka Join) [native array.js:180] [pc=000000A406C83FF2] (this=0000009DB9004241 ...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
@angular/cli: 1.3.0
node: 6.11.2
os: win32 x64
sbabeal commentedon Aug 18, 2017
How is upgrading to typescript 2.4.2 working. You will get build issues from RxJs as they 2.4 broke the typings of rxjs
sbabeal commentedon Aug 18, 2017
This problem is happening as well for our project. Can't build aot on build server with the same javascript heap out of memory. We are also using the experimental webpack 3 support.
josephliccini commentedon Aug 18, 2017
@sbabeal just go to RxJS 5.4.2
chriseenberg commentedon Aug 18, 2017
For us - building locally with
ng build --target=production --environment=prod --base-href /myproject/ --aot --build-optimizerworks just fine, but when we build it on our server, we get the
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memoryerror. However, if we remove the --build-optimizer everything runs fine.
I've tried adding the
increase-memory-limitlibrary, but without any luck.Is there a fix to this that actually works?
Kind regards Chris
sbabeal commentedon Aug 18, 2017
Tried latest version of typescript and still didn't help. Locally it builds but consumes 1.5 gigs of memory. Seems quite excessive.
phamtuananh791994 commentedon Aug 21, 2017
92% chunk asset optimization
<--- Last few GCs --->
[3933:0x2a7d710] 355436 ms: Mark-sweep 1395.8 (1546.4) -> 1395.3 (1546.4) MB, 975.3 / 0.0 ms allocation failure GC in old space requested
[3933:0x2a7d710] 356584 ms: Mark-sweep 1395.3 (1546.4) -> 1395.3 (1546.9) MB, 976.0 / 0.0 ms allocation failure GC in old space requested
[3933:0x2a7d710] 357953 ms: Mark-sweep 1395.3 (1546.9) -> 1395.3 (1539.9) MB, 1195.7 / 0.0 ms last resort
[3933:0x2a7d710] 359143 ms: Mark-sweep 1395.3 (1539.9) -> 1395.3 (1539.9) MB, 1188.8 / 0.0 ms last resort
<--- JS stacktrace --->
==== JS stack trace =========================================
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [@angular/cli]
2: 0x12b717c [@angular/cli]
3: v8::Utils::ReportOOMFailure(char const*, bool) [@angular/cli]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [@angular/cli]
5: v8::internal::Factory::NewCode(v8::internal::CodeDesc const&, unsigned int, v8::internal::Handlev8::internal::Object, bool, bool, int, bool) [@angular/cli]
6: v8::internal::CodeGenerator::MakeCodeEpilogue(v8::internal::MacroAssembler*, v8::internal::EhFrameWriter*, v8::internal::CompilationInfo*, v8::internal::Handlev8::internal::Object) [@angular/cli]
7: v8::internal::FullCodeGenerator::MakeCode(v8::internal::CompilationInfo*, unsigned long) [@angular/cli]
8: v8::internal::FullCodegenCompilationJob::ExecuteJobImpl() [@angular/cli]
9: v8::internal::CompilationJob::ExecuteJob() [@angular/cli]
10: 0xd577dc [@angular/cli]
11: 0xd59faa [@angular/cli]
12: 0xd5b7a9 [@angular/cli]
13: v8::internal::Compiler::Compile(v8::internal::Handlev8::internal::JSFunction, v8::internal::Compiler::ClearExceptionFlag) [@angular/cli]
14: v8::internal::Runtime_CompileLazy(int, v8::internal::Object**, v8::internal::Isolate*) [@angular/cli]
15: 0x3e6ef29040c7
Aborted (core dumped)
linkevin777 commentedon Aug 21, 2017
We seem to face the error even on allocating 12GB of memory for the build.
Is there any way to debug what is causing the memory leak? also, could this be solved by implementing lazy loading of modules, since this is during build time?
Commands used:
1.node --max_old_space_size=12000 ./node_modules/@angular/cli/bin/ng build --prod --aot --env=prod
2. updated the ng to accept the --max_old_space_size parameter
The build is working only with --sourcemap=false and --aot=false; but this is causing memory leaks and page load issues in the browser due to huge application size.
StackTrace:-
[INFO]
[INFO] <--- Last few GCs --->
[INFO]
[INFO] [11944:0x2710b70] 898052 ms: Mark-sweep 11998.2 (13529.5) -> 11998.2 (13529.5) MB, 4991.9 / 0.0 ms allocation failure GC in old space requested
[INFO] [11944:0x2710b70] 903445 ms: Mark-sweep 11998.2 (13529.5) -> 11998.1 (13434.0) MB, 5366.9 / 0.0 ms last resort
[INFO] [11944:0x2710b70] 908749 ms: Mark-sweep 11998.1 (13434.0) -> 11998.1 (13378.0) MB, 5266.9 / 0.0 ms last resort
[INFO]
[INFO]
[INFO] <--- JS stacktrace --->
[INFO]
[INFO] ==== JS stack trace =========================================
[INFO]
[INFO] Security context: 0x2b8a8b3a66a1
[INFO] 1: DoJoin(aka DoJoin) [native array.js:~97] [pc=0x168f8ea1398a](this=0x38d692102311 ,q=0x39d30737fbe1 <JS Array[2905]>,r=2905,F=0x38d6921023b1 ,B=0x38d692157ff9 <String[1]: >,A=0x38d692102421 )
[INFO] 2: Join(aka Join) [native array.js:~122] [pc=0x168f8e9b25e2](this=0x38d692102311 ,q=0x39d30737fbe1 <JS Array[2905]>,r=2905,B=0x38d692157ff9 <String[1]: >,A=0x...
[INFO]
loic49 commentedon Aug 21, 2017
I don't know if it can help someone but we had the same problem after upgrading to version 1.3.0. And we had others problem too : slow compilation and bad names for generated chunk.
All our problems were solved with this : #7338
Masquer commentedon Aug 22, 2017
There's always an option to eject the app.
linkevin777 commentedon Aug 22, 2017
randyaa commentedon Aug 22, 2017
Still a problem for us even after CLI upgrade to 1.3.1 and @angular upgrade to 4.3.5
tried typescript 2.5 but run into some compilation problems. we're on 2.4.2.
edited:
On our local machines or our gitlab runner instances we can't reproduce the problem. For some reason the build only fails on our jenkins box. The only difference I've been able to gather is jenkins is on a slightly older version of node/npm version:
instead of
fixed by changing our production npm build script to:
Not so much a fix as it is a brute force work-around, but it'll at least buy time while we figure out what's eating up all the heap space.
Masquer commentedon Aug 22, 2017
@notsonotso oh, it will not then.
my app, however, fails to compile by ng with 'heap out of memory' error, but does as ejected.
mgechev commentedon Aug 24, 2017
Here's a related, solved issue in angular-seed. I hope it helps someone.
mattem commentedon Aug 24, 2017
No amount of setting
max-old-space-sizehelped on our project. However, as we only build AOT in prod, we have temporarily disabled sourcemaps which seemed to fix it for us on our CI server.timwright35 commentedon Aug 24, 2017
Like @mattem I have not been able to get the max-old-space-size to work either. I do not if I am fully setting it up right though since the build process I have uses webpack with "ngtools/webpack".
bgever commentedon Aug 25, 2017
Same issue, but we've found a more reliable workaround to increase the memory limit.
Since Node 8.x, you can set a
NODE_OPTIONSenvironment variable, and pass in the--old-max-space-sizeflag. We currently need 6GB.E.g. on Windows CMD:
set NODE_OPTIONS=--old-max-space-size=6411before running the AOT build.I wonder if there is a child process that doesn't get the arguments that are set on the node executable.
bgever commentedon Aug 25, 2017
I know, and trust me, I'm just as much struggling with this. Not fun when the build server starts to run out of memory. It's a serious problem that should be addressed. This workaround just helped me to limp along a little farther, just like turning off the source maps. Your mileage may vary.
eduardotolino commentedon Aug 31, 2017
Hello.
this problem is serious.
On my computer I was limiting to 8Gb and the ng build was working fine.
(with old-max-space-size)
But now I've got a big big project and believe me, out of memory.
I have a code generator that builds everything perfectly.
but the new project has more than 200 entities.
The creation of modules and lazy loading depends on the settings made by the client and their entities.
I would not want to separate in several applications because there is a lot of dependency.
(200 services, 600 components)
The project runs fine with ng serve, but not with ng build.
I rented a virtual machine with 28Gb ram and believe me, did the build using 27Gb of RAM.
The service node occupied exactly 27Gb.
(I put the limit of 28gb)
Everything works fine with ng serve.
can anyone know to tell me if just separating into several lazy loading modules it will need less memory to compile with ng build? or it works only to separate the JS?
I can not rent a virtual machine whenever I need to run ng build.
And the effort of change will be very high.
So I needed to be sure of what to do.
Thanks.
joecot commentedon Aug 31, 2017
@tolitech Instead of depending on having enough RAM for this to build, just add swap to your machine. The build will be a little slower, but you don't need to be renting machines with 28 GB of RAM.
I too want this to be resolved ASAP, but adding swap space gets around the memory issue.
eduardotolino commentedon Aug 31, 2017
@joecot Thank you.
I'll try to do this and see if it works.
If it works, I do not see any problems if it takes 8 hours.
I leave a night job for publication without problems.
That was a good idea.
I'll try.
Thank you.
eduardotolino commentedon Sep 1, 2017
@joecot @notsonotso
It worked.
I configured 32Gb virtual memory (swap), --max_old_space_size and finally worked.
It used the 28gb (It's too high), but it worked.
Thank you very much for the idea, @joecot
bgever commentedon Sep 1, 2017
@mhevery @bradlygreen - apologies for pulling you into this one, but with @tolitech's extreme case above, the value proposition of Angular is starting to become seriously undermined.
Our codebase is growing rapidly, and our team is continuously running into these memory issues, where we even reach the limitations of our development and build machines. In all my years of web development there's never been a case that I would run out of the capabilities of the machine, just to compile to several 300k files for my webapp/website. It seems to be a memory optimization or architectural issue that hopefully can be avoided.
We've already lost countless hours on these problems, and the premise that Angular is a framework that scales for large enterprise applications doesn't hold up anymore.
I'd really appreciate if this issue could be prioritized, as I'm really starting to doubt whether our choice of Angular as a suitable framework was correct, considering that only the AOT builds are performant and small enough to ship to customers over the wire, and that we're struggling to get those to work. Thank you.
xnnkmd commentedon Sep 1, 2017
@bgever Apparently google is not using angular-cli/webpack themselves, so they don't run into problems like this. I suspect this is why this problem receives so little attention from the angular developers. If this continues, the community should be publicly warned about angular being unsuitable for large projects.
eduardotolino commentedon Sep 1, 2017
You were perfect in your words, @bgever .
I'm already thinking that Angular does not work for large applications, after all I'm now needing 28 Gb of RAM and the project could grow bigger. (This is the first day of this application).
I'm already thinking about another strategy for this type of project, maybe even change technology because I'm realizing that this problem is occurring with many people and for a long time.
I believe my customer will not accept me saying that he needs 28 Gb RAM to compile his own project.
I'm very worried about this.
Dunos commentedon Sep 1, 2017
I'm just staying in Angular CLI 1.2.7 while they fix this, hope they do it soon tho, but with 1.2.7 I have no memory problems at all.
bjornharvold commentedon Sep 7, 2017
Same here. Running Angular CLI 1.3.2 and Angular 4.3.6. Added this based on another thread to get it to work. My app isn't very big but CLI clocked in at 4GB to build my app.
elvisbegovic commentedon Sep 7, 2017
@bjornharvold @tolitech We need 1024go ram 32ghz cpu, so 32'000'000'000 calcul per second to build angular but if you learn bazel from google it can be faster 😂
gtarun commentedon Sep 8, 2017
https://github.com/endel/increase-memory-limit
This worked for me
hugodes commentedon Sep 14, 2017
Same problem here.
I had to downgrade to @angular/cli 1.2.6 with TS 2.4.2 for the build to work again.
A shame I can't use the latest angular cli ... Why isn't this considered a severe bug ?
alexzuza commentedon Sep 14, 2017
@hugodes
I think it is because of angular/angular#19058
phamtuananh791994 commentedon Sep 28, 2017
Lastest version is the same !
DutchKevv commentedon Sep 28, 2017
Same here, this is ridiculous. I'm using a cheap VPS server to build and it simply crashes with 2GB of memory
hugodes commentedon Sep 28, 2017
What solved it for me was doing ng build --prod instead of ng build --aot --prod.
The --prod option already includes the --aot one, and optimises the build process and I'm not getting memory errors any more.
Hope it helps some of you guys.
aminebizid commentedon Sep 28, 2017
Try -sm false
jota0222 commentedon Oct 6, 2017
It happens to me when the allowJS parameter is true in tsconfig.json. Apparently, the javascript files are overloading the memory.
clevagroup commentedon Oct 10, 2017
This worked for me, add to package.json scripts section. Watching the memory usage in task manager it got up to around 4gb usage. Seems a touch excessive!
"build2": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod --aot"
npm run build2
tupham commentedon Oct 14, 2017
This command works for me:
node --max-old-space-size=4096 ./node_modules/@angular/cli/bin/ng build --prod
"scripts":{
"prod": "node --max-old-space-size=4096 ./node_modules/@angular/cli/bin/ng build --prod"
}
tossp commentedon Oct 23, 2017
try process.nextTick() ?
marcalj commentedon Oct 23, 2017
With Node 8.x and latest cli version works without any hack :)
andremarcondesteixeira commentedon Oct 23, 2017
Sad to see that months have passed and this issue is still not solved. I'm having the same problem here:
´
ng build --aot
92% chunk asset optimization
<--- Last few GCs --->
191455 ms: Mark-sweep 1296.7 (1433.7) -> 1291.4 (1434.7) MB,
1052.3 / 0.0 ms [allocation failure] [GC in old space request
ed].
192605 ms: Mark-sweep 1291.4 (1434.7) -> 1291.4 (1434.7) MB,
1150.6 / 0.0 ms [allocation failure] [GC in old space request
ed].
193711 ms: Mark-sweep 1291.4 (1434.7) -> 1294.8 (1403.7) MB,
1105.0 / 0.0 ms [last resort gc].
194808 ms: Mark-sweep 1294.8 (1403.7) -> 1298.3 (1403.7) MB,
1097.0 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 00000146E3DCF791
2: addMapping(aka SourceMapGenerator_addMapping) [D:\Users
\andre.marcondes\projects\lender-platform\node_modules\source-
map\lib\source-map-generator.js:~94] [pc=00000339B436339E] (th
is=0000015776039641 <a SourceMapGenerator with map 00000102C1F
AA599>,aArgs=00000004C17F22D1 <an Object with map 00000194E061
0DD9>)
3: /* anonymous */ [D:\Users\andre.marcondes\projects\lend
er-platform\node...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScrip
t heap out of memory
´
zackschuster commentedon Oct 23, 2017
@notsonotso an ng team member told me this has to do with poor recursion handling in
@ngtools/webpack, i'm curious what webpack's faults are?MrBlaise commentedon Oct 26, 2017
Started happening to me using macOS 10.13
On Windows it builds fine, both machines using the same configuration and have 16 gigs of ram.
MbuelensAM commentedon Oct 26, 2017
I went back to version 1.2.x and didn't have any exceptions there.
1.3.x and 1.4.x all gave the memory exception.
MrBlaise commentedon Oct 26, 2017
@filipesilva Is there any news regarding to this issue?
I'm curious why a semi-large project needs more than 2 gigs to build. I am not familiar with the inner workings of the compilation process, but it seems rather high to me.
EDIT:
using the --build-optimizer flag causes the issue, it was working fine, but I recently upgraded the cli and I see that it uses a newer build-optimizer (0.0.31), maybe memory leak on the optimizer?
elvisbegovic commentedon Oct 26, 2017
@MrBlaisee you mean 20* Go
!!
GenweiWu commentedon Oct 28, 2017
try
ng build --aot --sourcemaps=false,it seems there is problem with
sourcemaps.elvisbegovic commentedon Oct 28, 2017
Lol with or without sourcemap it depend how long node is working! Hope this will be fixed one day
tupham commentedon Oct 31, 2017
I am using 6.9.4 Nodejs and Angular 4.5, Angular-cli 1.4.6 but no lucks
We need hacks above.
muhammadsaaeed commentedon Oct 31, 2017
Got an issue resolved on one of the machine using below:
Try this out:
In "ProjectDirectory\node_modules\.bin" modify webpack.cmd to:
@if EXIST "%~dp0\node.exe" (
"%~dp0\node.exe --max_old_space_size=4096 " "%~dp0..\webpack\bin\webpack.js" %*
) ELSE (
@SETLOCAL
@set PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=4096 "%~dp0..\webpack\bin\webpack.js" %*
)
and try to build.
Basically, its going to use --max_old_space_size=4096 with node webpack build.
See if that helps.
ar53n commentedon Nov 2, 2017
Angular 5 and angular-cli 1.5. Have problems
--aotmbrookson commentedon Nov 2, 2017
Also hit this memory issue. Can be 'resolved' by using the build script
node --max-old-space-size=4096 ./node_modules/@angular/cli/bin/ng build --prodbut hopefully this bug will be fixed soon. Why does it need over 2GB of memory?!RicardoVaranda commentedon Nov 3, 2017
Also facing the same issue currently, our app has over 50 components spread across 6 modules.
dpxxdp commentedon Nov 3, 2017
We are experiencing the same issue... eclipsing 3GB of memory in a medium-large application. We have ~20 modules each with 5-8 components.
filipesilva commentedon Nov 4, 2017
Hey all, I'm seeing a lot of new reports of this happening after 1.5 is out. One of the changes we did for 1.5 was to use Build Optimizer by default on Angular version 5 projects. Build optimizer does indeed use a lot of memory (angular/devkit#240).
Can you tell me if turning off build optimizer helps with your memory crashes? You can do it with
--build-optimizer=false. Turning off sourcemaps can also help via--sourcemaps=false.If these options don't help, can you post here the full failure log please, including command run?
mscahill commentedon Nov 4, 2017
--build-optimizer=falsehelps in my case.I have a large app (30 modules, 263 components).
With @angular: 4.4.6 ; @angular/cli: 1.4.9 I can get a --prod build with
--max_old_space_size=6144but with @angular: 5.0.0 ; @angular/cli: 1.5.0 I run out of memory even with--max_old_space_size=8192. I can get a build with--max_old_space_size=10240, but my CI does not support that configuration.However, with
--build-optimizer=falseI can build with--max_old_space_size=6144williangd commentedon Nov 6, 2017
Tests with angular-cli 1.5
ng build --prod build-optimizer=false --sourcemaps=false (I canceled after 12 minutes running)
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --prod build-optimizer=false --sourcemaps=false (work after 4,2 minutes)
dpxxdp commentedon Nov 6, 2017
@filipesilva, @hansl, Before anything, thanks so much for this project- Angular has been great for our team. We love the framework and we love the CLI so thanks for all your hard work.
This memory issue seems like it is becoming a real problem. I'm looking for some messaging from the Angular team around expectations here, and I'd be happy to give whatever data is necessary to help move it forward.
Our team is an enterprise team with a medium-large app. We ran into this memory issue a while back, and upped the
max_old_space_sizeto 1GB and then later 2GB. Each time it solved our problem for a few months. But as the app continues to grow we've run into it again now and we can't do this forever. Our toolchain uses Bitbucket pipelines, which like many other CI's maxes out available memory (3GB is our max given our other needs), so we're beginning to run up against a wall.I've been taking some benchmarks with our app, it looks like you're correct in your post above: 1.5.0, with
--build-optimizer=falseuses equivalent memory to 1.4.5.Our app has ~180 components and ~30 services across ~22 modules. I'd like to think it is constructed in a reasonably smart manner, following best practices and general clean code design. The
build --aot --build-optimizer=false --sourcemaps=falsefor this project using 1.5.0 now takes about 2925 GB of memory.Two general questions for you and others, about (1) expectations and (2) short-term alleviation:
(1) Is Angular built for enterprise development? If so, this issue seems to be of the highest priority and the community deserves more frequent and clear messaging on this. If not, your users need to know this because lots of decisions across hundreds of companies ride on that.
(2) Are there any recommendations from the Angular team about ways to alleviate this issue?
Again, I'd be happy to test any theories/provide data about our large application to help get to the bottom of this, and again, thanks for all the hard work you've done on this.
jason-d-hobbs commentedon Nov 6, 2017
In our case, the build optimizer nor the sourcemaps flags were effective. Downgrading to @angular/cli 1.4.9 fixed it.
Worked without either flag set false:
DIDN'T Work even with both flags set false:
...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
We have not tried the hacks above on changing the old space memory... our application isn't apparently as big as some of the others on this thread, but yet fails on cli 1.5.0.
danny-swimmer commentedon Nov 7, 2017
@filipesilva: --build-optimizer=false and --sourcemaps=false works for me with cli 1.5.
Without them, I was getting "JavaScript heap out of memory".
Thanks for your help!
adamzhu-xs commentedon Nov 8, 2017
Happens for me also. Wired part is error thrown after bundle files generated.
Angular CLI: 1.5.0
Node: 8.9.0
OS: win32 x64
Angular: 5.0.0
<--- Last few GCs --->
[12192:00000000004C39A0] 236834 ms: Mark-sweep 1420.3 (2200.9) -> 1420.3 (2159.4) MB, 578.6 / 0.0 ms last resort GC in old space requested
[12192:00000000004C39A0] 237461 ms: Mark-sweep 1420.3 (2159.4) -> 1420.3 (2136.9) MB, 627.2 / 0.0 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000000B4C7AA5EC1
1: DoJoin(aka DoJoin) [native array.js:~95] [pc=0000001391AFE299](this=000001A846C82311 ,p=00000050BD62B091 <JSArray[576]>,q=576,E=000001A846C823B1 ,A=000000B4C7AEEC69 <String[1
]: >,z=000001A846C82421 )
2: Join(aka Join) [native array.js:~120] [pc=0000001390C722A9](this=000001A846C82311 ,p=00000050BD62B091 <JSArray[576]>,q=576,A=000000B4C7AEEC69 <Str...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! mobx-ui-test-app@0.0.0 build:prod:
ng build --env=prod --prod --aot --stats-json --named-chunks=true --sourcemaps=falsenpm ERR! Exit status 3
==== update ======
Issue for me is --stats-json. Build is fine after remove this flag.
swftvsn commentedon Nov 8, 2017
Optimizations are welcome, but on the other hand memory is cheap. Until optimizations are here run the build using
node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng buildand append whatever switches you'd like to the end. To make it easier to run, edit your package.json file and add this line to "scripts":
"serve": "node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng serve --aot"Then you can execute it using
npm run serveI'm an old Java dev, so this seems familiar to me somehow :)
elclanrs commentedon Nov 8, 2017
@swftvsn, memory is cheap if you have control over it, but we deploy to a Docker swarm, and containers have limited memory. This is a pretty serious issue for us. I'd prefer a slower build if that means caching stuff to disk and not running out of memory.
tim-white87 commentedon Nov 8, 2017
I am getting this issue after upgrading to cli 1.5 and angular 5.0.
I want to highlight the question above:
I am so confused why any compiler would need 4 gigs of memory to compile a web app..... To get it to compile aot post upgrade I had to jack the memory up to 4 gigs. Our app has 2 feature module libraries each with about 15 modules, ~60 modules in the main app, and ~15 services. We have a lot left to build as well.
swftvsn commentedon Nov 8, 2017
I would imagine it has to do with the obscene amount of dependencies + all the hoops that are done to statistically analyze all the dependencies and your code in order to shake the trees. Take a look at node_modules if you dare. (And source / debug maps and things I don't even know about)
Excessive memory consumption is usually caused by a lot of data and/or abstraction over abstraction over abstraction over... :) Or a bug.
For now I'm happy and I just feed the beast. I do hope it looses some of it's appetite in the coming versions though..
dpxxdp commentedon Nov 9, 2017
I'm less concerned about "how could this possibly...?" than I am about the lack of communication.
The compilation itself is doing some pretty heavy lifting right now. It's really great actually. The entire CLI is. It bundles this thing up and serves it pretty compactly. In fact his may be a testament to just how easy Angular makes it to build large scale web apps... their size is outpacing the toolchain.
I'm just looking for the Angular team to set expectations here, that's all:
Any answer to those questions is okay... but it's important that those answers (and their progress) are communicated to the community in an iterative fashion. My team and many other teams need to make decisions based off those answers, and right now we feel frozen.
This is an open source project that we're all getting for free. It's added tremendous value already even with this issue; so some people are being awfully critical given this. At the same time, open communication is integral to the success of solid open source projects: we're looking to the Angular team for that leadership.
@filipesilva , @hansl?
swftvsn commentedon Nov 9, 2017
That's an excellent summary @dpxxdp !
changLiuUNSW commentedon Nov 9, 2017
Recent upgrade our project to Angular 5 and Angular CLI 1.5.
We have 100+ components and 20+ modules. The
build --prodis taking forever and finally throw heap out of memory exception which is very frustrating!eduardotolino commentedon Nov 9, 2017
As I mentioned here a few months ago, I have a very large project with several modules too, +120 pages, +500 components (pages are divided into at least 3 components like grid, form).
To get ng build -prod to work I had to test on a machine with 32 Gb of RAM, nodeJS consumed 28 Gb to compile the project. Impressive.
The solution was actually put 32 Gb as virtual memory on the machine (swap).
In addition, of the already known "--max_old_space_size".
changLiuUNSW commentedon Nov 9, 2017
The label of this issue should be
priority: 1 (urgent)rather thanpriority: 2 (required)tim-white87 commentedon Nov 9, 2017
@swftvsn I am still not getting it. Maybe it is because I come from .NET where the c# compiler would tear through a project with comparable amounts of classes without breaking a sweat.
@tolitech This is exactly the main point. If we need machines with 32 GB of ram to build the project, some cloud agents won't be able to handle this/aren't configurable to upgrade the hardware. Thus, we would need to make architectural decisions to start building segmented SPAs to keep the size of a project down, catering to compiler limitations.
@dpxxdp While I do agree that it is great that it is free and open source (thanks as well team!), I don't feel that it is a criticism to report a major bug/functional limitation that requires a hardware upgrade as a work around. I don't think anyone is trying to criticize the work that was done, but rather increase the priority on this issue.
WandererInVoids commentedon Nov 9, 2017
guys 2 workaround for heap problem
currently default build use several optimization step + minification.
ng build --app app -aot=true -e=prod -sm=false -ec=true --named-chunks=false -oh=all -pr=falsethis will generate bundles without minification and general size for vendor bundle will increased in my case for 8%. Build time decreased for twice, but minification step take long time 6-7 min in CI machine (2gb). I use gulp for post build actions in my case its uglify js and postcss.
My app
~72 services (CRUD operation + some general logic)
~10 pipe
~15 directive
~170 components
~ 80 model class (data from API)
~ 15 module
as for me i want some flags to set optimization step count, tree shake deep (function, class, variable)
filipesilva commentedon Nov 9, 2017
Hi all,
I've bumped the priority on this issue and will be working on it. We didn't consider it to be as urgent before because the solution at the time was to increase the available memory to node, which defaults to 1.7gb. So it was expected that at some point projects would need more memory than the default.
However with the release of 1.5 the memory requirements seem to have increased dramatically. Projects that didn't have any memory problems before now do. 32gb is definitely a ridiculous amount of RAM and shouldn't be needed.
At this point I'm not sure what caused the memory spike but have a few hypothesis. With CLI1.5 + Angular 5 we use a new pipeline that does better type checking by using a full TS program. Maybe there's a bad cache somewhere in there, or the TS program is taking a lot of memory. Another possibility is Uglify, which we had to upgrade as well. Or it might be something in the AOT compiler itself. We also default build optimizer to true now and it's not really optimized for neither speed nor memory.
If you're running into this problem and have time, I'd appreciate if you could answer a couple questions:
ng build --prod?ng build --prod --build-optimizer=falseng build --aotng build --aot --build-optimizerYeomansIII commentedon Nov 9, 2017
In response to above comment:
CLI 1.5.0, Angular 5.0.1
Project:
Services: 9
Components: 43
Models: 28
Lines of ts: 8200
Lines of sass: 5000
Heap error happens with:
ng build --prod: yesng build --build-optimizer=false: nong build --aot: nong build --aot --build-optimizer: noetiennetalbot commentedon Nov 9, 2017
@filipesilva
About 20 modules, 30 services, 80 components
Can't show the repo unfortunately
WandererInVoids commentedon Nov 9, 2017
@filipesilva
What version of the CLI and Angular are you on?
1.5.0 angular 5.0.1
Does this only happen on ng build --prod?
yes
Do you still get the memory error with these build commands:
ng build --build-optimizer=falsenong build --aotnong build --aot --build-optimizernojmcclanahan commentedon Nov 9, 2017
@filipesilva
Windows 7 Pro 64-bit
12 Gigs of ram
CLI 1.5.0, Angular 5.0.0
Project details:
~120 components
15 modules
Do you still get the memory error with these build commands:
ng build --prod: yes
ng build --build-optimizer=false: no
ng build --aot: no
ng build --aot --build-optimizer: yes
dpxxdp commentedon Nov 9, 2017
On Angular 4.3
with ~180 components
with ~30 services
with ~22 modules
With CLI 1.5
Does this only happen on ng build --prod? Yes
ng build --build-optimizer=false less than 2GB
ng build --aot --build-optimizer=false ~2.8GB
ng build --aot over 3 GB
With CLI 1.4.5
Does this only happen on ng build --prod? Yes
ng build --build-optimizer=false less than 2GB
ng build --aot --build-optimizer=false ~2.8GB
ng build --aot ~2.8 GB
Our repo is private unfortunately
garkbit commentedon Nov 9, 2017
CLI 1.5.0, Angular 5.0.0
Modules: ~50
Services: ~110
Components: ~290
ng build --prod: failng build --prod --build-optimizer=false: failng build --prod --build-optimizer=false --sourcemaps=false: failng build --prod --aot=false: worksng build: worksng build --aot=true: worksng build --aot=true --build-optimizer=true: failAntonisFK commentedon Nov 9, 2017
What version of the CLI and Angular are you on?
@angular/cli@1.5.0,@angular 5.0Does this only happen on ng build --prod?
yes
Do you still get the memory error with these build commands:
ng build --build-optimizer=false: NOng build --aot: NOng build --aot --build-optimizer: NOelvisbegovic commentedon Nov 9, 2017
Under cli1.5 & angular5
Ng build —prod : YES
Ng serve —aot : first time NO but after editing file YES it throw error out of memory... blockin at 0%
Ng serve : NO all’s okay and fast (but wait a lot to show result in browser because of JiT compiler)
Cc @filipesilva
Satyadatla commentedon Nov 10, 2017
The versions I am using
CLI - 1.2.0 and Angular 4.2.5
Modules: ~ 130
Components: ~ 200
Services: ~ 70
getting the build issues with below options.
ng build --prod: fail
ng build --aot=true: fail
ng build --aot=true --sourcemaps=false : Works most of the times and very often it is failing.
ng build --prod --aot=false : works
swftvsn commentedon Nov 10, 2017
@cecotw sarcasm is sometimes misinterpreted. And I'm not here to fire up any flamewars, your ecosystem is obviously the better :)
rejayi-experion commentedon Nov 10, 2017
I had experienced the issue
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memorywithng build --prod. I have solved the problem by usingnode --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod
You can add also in
as
magemello commentedon Nov 10, 2017
What version of the CLI and Angular are you on?
Does this only happen on ng build --prod? NOT SURE
Do you still get the memory error with these build commands:
also:
If you have a project that I can look at, can you link it please?
we have a gitter channel if you need help to build our project and have a look:
JonathanYates commentedon Nov 12, 2017
Same issue. Upgraded to A5. ng build --prod results in out of memory error below. The error does not occur without --prod. Increasing the --max_old_space_size is not really the answer, something is fundamentally wrong and has stopped our A5 upgrade going anywhere.
Please fix!
<--- Last few GCs --->
243344 ms: Mark-sweep 1000.9 (1434.4) -> 1003.2 (1434.4) MB, 452.4 / 0.0 ms [allocation failure] [scavenge might not succeed].
243760 ms: Mark-sweep 1003.2 (1434.4) -> 1003.2 (1434.4) MB, 416.3 / 0.0 ms [allocation failure] [scavenge might not succeed].
244187 ms: Mark-sweep 1003.2 (1434.4) -> 1012.9 (1418.4) MB, 427.0 / 0.0 ms [last resort gc].
244591 ms: Mark-sweep 1012.9 (1418.4) -> 1022.8 (1418.4) MB, 403.8 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x957966cfb39
1: DoJoin(aka DoJoin) [native array.js:~129] [pc=0xbe4173aee59] (this=0x95796604381 ,w=0x1ca9328ff671 <JS Array[939]>,x=939,N=0x957966043c1 ,J=0x957966ae4b9 <String[1]: >,I=0x957966b46c9 <JS Function ConvertToString (SharedFunctionInfo 0x95796652dc9)>)
2: Join(aka Join) [native array.js:180] [pc=0xbe419f08ab2] (this=0x95796604381 ,w=0x1ca9328ff671 <JS Array[9...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Localv8::Value, v8::Localv8::Message) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
5: v8::internal::Runtime_StringBuilderJoin(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
6: 0xbe4066092a7
Abort trap: 6
radoslavpetranov commentedon Nov 12, 2017
What version of the CLI and Angular are you on?
ng build --prod- Successng build --build-optimizer=false- Successng build --aot- Successng build --aot --build-optimizer- OOMEA sanity-check local run of
ng serve --prod --aotgave me failure at a later timeIn my project everything was working fine in
--prod --aotmode up until a day ago when I decided to migrate toHttpClientto prepare for the Angular 5 / CLI 1.5 switch. No version changes, no CLI changes were involved.I upgraded my services and moved some error/auth logic to a couple of interceptors. My vendor dev bundle went from 15MB to 6MB and I was all impressed. Then I decided to sanity check my prod aot build with
ng serve --prod --aotand I started getting the OOME.jayhamilton commentedon Nov 13, 2017
Seeing the same issue after upgrading to cli 1.5, Angular 1.5 and HttpClient
$ ng build --aot --prod
95% emitting
<--- Last few GCs --->
224719 ms: Mark-sweep 1304.7 (1434.7) -> 1304.7 (1434.7) MB, 485.6 / 0.0 ms [allocation failure] [scavenge might not succeed].
225206 ms: Mark-sweep 1304.7 (1434.7) -> 1304.7 (1434.7) MB, 487.0 / 0.0 ms [allocation failure] [scavenge might not succeed].
225685 ms: Mark-sweep 1304.7 (1434.7) -> 1304.7 (1418.7) MB, 479.3 / 0.0 ms [last resort gc].
226180 ms: Mark-sweep 1304.7 (1418.7) -> 1304.7 (1418.7) MB, 494.5 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x3e4edad3fa99
1: DoJoin(aka DoJoin) [native array.js:~129] [pc=0xd5adf91512e] (this=0x3e4edad04241 ,w=0x21eed50e5b41 <JS Array[754]>,x=754,N=0x3e4edad04281 ,J=0x3e4edad4a369 <String[1]: >,I=0x3e9e792bc1e9 <JS Function ConvertToString (SharedFunctionInfo 0x3e4edad5dbc9)>)
2: Join(aka Join) [native array.js:180] [pc=0xd5ac9783c52] (this=0x3e4edad04241 ,w=0x21eed50e5b41 <JS ...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Localv8::Value, v8::Localv8::Message) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
5: v8::internal::Runtime_StringBuilderJoin(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
6: 0xd5ac97060c7
7: 0xd5adf91512e
Abort trap: 6
Jays-MacBook-Pro:ngx-dynamic-dashboard-framework jayhamilton$ ng build --aot --prod
95% emitting
<--- Last few GCs --->
224540 ms: Mark-sweep 1305.3 (1444.7) -> 1305.3 (1444.7) MB, 476.2 / 0.0 ms [allocation failure] [scavenge might not succeed].
225007 ms: Mark-sweep 1305.3 (1444.7) -> 1305.3 (1444.7) MB, 466.7 / 0.0 ms [allocation failure] [scavenge might not succeed].
225479 ms: Mark-sweep 1305.3 (1444.7) -> 1305.3 (1428.7) MB, 471.9 / 0.0 ms [last resort gc].
225970 ms: Mark-sweep 1305.3 (1428.7) -> 1305.3 (1428.7) MB, 491.1 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x67c5bb3fa99
1: DoJoin(aka DoJoin) [native array.js:~129] [pc=0x337898eca1ce] (this=0x67c5bb04241 ,w=0x3ba9f97f5a79 <JS Array[754]>,x=754,N=0x67c5bb04281 ,J=0x67c5bb4a369 <String[1]: >,I=0x2b42504bc1e9 <JS Function ConvertToString (SharedFunctionInfo 0x67c5bb5dbc9)>)
2: Join(aka Join) [native array.js:180] [pc=0x33787d083c52] (this=0x67c5bb04241 ,w=0x3ba9f97f5a79 <JS Arra...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Localv8::Value, v8::Localv8::Message) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
5: v8::internal::Runtime_StringBuilderJoin(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
6: 0x33787d0060c7
7: 0x337898eca1ce
Abort trap: 6
PACKAGE.JSON
"dependencies": {
"@angular/animations": "^5.0.1",
"@angular/cdk": "2.0.0-beta.12",
"@angular/common": "^5.0.1",
"@angular/compiler": "^5.0.1",
"@angular/core": "^5.0.1",
"@angular/forms": "^5.0.1",
"@angular/http": "^5.0.1",
"@angular/material": "2.0.0-beta.12",
"@angular/platform-browser": "^5.0.1",
"@angular/platform-browser-dynamic": "^5.0.1",
"@angular/router": "^5.0.1",
"@swimlane/ngx-charts": "6.1.0",
"core-js": "^2.4.1",
"d3": "^4.4.0",
"jquery": "2.2.0",
"ng2-cookies": "1.0.3",
"ng2-dnd": "^2.1.1",
"reflect-metadata": "0.1.8",
"rxjs": "^5.5.2",
"semantic-ui": "2.2.2",
"socket.io-client": "^1.7.2",
"sockjs-client": "^1.1.4",
"stompjs": "^2.3.3",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.5.0",
"@angular/compiler-cli": "^5.0.1",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.6.1"
}
hanvyj commentedon Nov 13, 2017
EDIT working with the
--max_old_space_size=8192fix above**Also getting the exact same. Angular 4 build time, 2 minutes maybe? New angular 5 build time is 25 to fail with:
92% chunk asset optimization
<--- Last few GCs --->
1327460 ms: Mark-sweep 1306.9 (1405.9) -> 1306.9 (1414.9) MB, 1826.0 / 0.0 ms [allocation failure] [GC in old space requested].
1329363 ms: Mark-sweep 1306.9 (1414.9) -> 1306.9 (1414.9) MB, 1903.1 / 0.0 ms [allocation failure] [GC in old space requested].
1331374 ms: Mark-sweep 1306.9 (1414.9) -> 1313.4 (1405.9) MB, 2010.3 / 0.0 ms [last resort gc].
1333333 ms: Mark-sweep 1313.4 (1405.9) -> 1319.9 (1405.9) MB, 1958.0 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000002E7514CF791
2: with_parens [000002E751404381 :~5813] [pc=000002F02F5400F6] (this=000001E1DBFE4699 <an Object with map 000001764956B2F9>,cont=000000E96E71C3A9 <JS Function (SharedFunctionInfo 0000030749384359)>)
3: /* anonymous /(aka / anonymous */) [000002E751404381 :6817] [pc=000002F02FE08F44] (this=000002E751404381 ,self=00000314C2BB6571 <an AST_Call with map ...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
JonathanYates commentedon Nov 14, 2017
Any update on this? This issue was raised back in March and is now manifesting itself in Angular 5 (and 4) prod builds. Seems somehow to be related to HttpClient.
Please can you investigate as a priority as we can not go to production using Angular 5, which is currently not fit for purpose.
hugodes commentedon Nov 14, 2017
@JonathanYates #5618 (comment)
JonathanYates commentedon Nov 14, 2017
Yes I know, that was 5 days ago. I am asking for an update.
MichalEmbiq commentedon Nov 14, 2017
Same issues, should build app without problems with
ng build --prod@filipesilva: I'm asking for an update date.
etiennetalbot commentedon Nov 14, 2017
@andremarcondesteixeira we will all do what we please. This isn't the place to try to convince anybody to use another framework.
jmcclanahan commentedon Nov 14, 2017
@JonathanYates @MichalEmbiq @andremarcondesteixeira - Have you guys tried what @filipesilva suggested in #5618 (comment)? That seems to have worked for most people and it also worked for me. Seems like a sufficient work-around until the real issue is solved.