Angular-cli: 1.5.0 - cannot build with AOT or Build Optimizer: JavaScript heap out of memory

Created on 3 Nov 2017  Â·  13Comments  Â·  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.5.0
Node: 8.8.0
OS: linux x64
Angular: 4.4.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, tsc-wrapped

@angular/cdk: 2.0.0-beta.8
@angular/cli: 1.5.0
@angular/flex-layout: 2.0.0-beta.10
@angular/material: 2.0.0-beta.8
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.3.4
webpack: 3.8.1

Repro steps.

rm -rf node_modules/
npm install --save-dev @angular/cli@latest
npm install
ng build --prod --aot --build-optimizer

The log given by the failure.

<--- Last few GCs --->

[2824:0x3fc7030]  1761516 ms: Mark-sweep 1415.7 (1628.1) -> 1415.7 (1628.1) MB, 569.0 / 0.0 ms  allocation failure scavenge might not succeed
[2824:0x3fc7030]  1762152 ms: Mark-sweep 1415.7 (1628.1) -> 1415.7 (1594.6) MB, 635.9 / 0.0 ms  last resort GC in old space requested
[2824:0x3fc7030]  1762801 ms: Mark-sweep 1415.7 (1594.6) -> 1415.7 (1582.1) MB, 648.6 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x93392d25e91 <JSObject>
    1: DoJoin(aka DoJoin) [native array.js:~95] [pc=0x2117503e8e39](this=0x16b6da402311 <undefined>,p=0x2730411704a9 <JSArray[832]>,q=832,E=0x16b6da4023b1 <true>,A=0x
93392d6e551 <String[1]:  >,z=0x16b6da402421 <false>)
    2: Join(aka Join) [native array.js:~120] [pc=0x21174f16e629](this=0x16b6da402311 <undefined>,p=0x2730411704a9 <JSArray[832]>,q=832,A=0x93392d6e551 <String[1]:  >,
z=0x16b6da4024...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [ng]
 2: 0x121809c [ng]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [ng]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ng]
 5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [ng]
 6: v8::internal::Runtime_StringBuilderJoin(int, v8::internal::Object**, v8::internal::Isolate*) [ng]
 7: 0x21174ef8463d
[1]    2824 abort (core dumped)  ng build --prod  --aot --build-optimizer

Desired functionality.

After updating a project to CLI v1.5.0 builds with aot and build-optimizer should be successful

Mention any other details that might be useful.

I'm working with an existing medium to larger sized app and can build with AOT using cli v1.4.9. Using --build-optimizer failed with the same result as above so I tried updating my CLI to 1.5 to see if there were any improvements and can no longer build with AOT. The build will process for 15-20 minutes then crashes with the output above. At first I thought it could be related to devkit #240, but after running the build again with --build-optimizer=false the out of memory crash reoccurred. I am only able to successfully build by disabling aot and build-optimizer.

1 (urgent) broken

Most helpful comment

I agree that manually increasing the node memory allocation during a build will help it to succeed - but isn't this more of a red flag that something wrong is causing the cli to use a large amount of memory? Suddenly having to increase memory after a minor version bump is a bit concerning to me.

If this is to be the accepted norm I would be happy to put together a PR to document it so others don't think something is wrong, but would like confirmation from someone like @filipesilva first.

All 13 comments

I'm having the same issue since 1.5

I'm having the same issue in 1.4.2
But i try to increase node max_old_space_size when build
node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --prod
It work for me.

Same problema since 1.3 :(

Using node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --prod too.

@williangd
I try to increase --max_old_space_size=4096 to --max_old_space_size=5120 It work.

I agree that manually increasing the node memory allocation during a build will help it to succeed - but isn't this more of a red flag that something wrong is causing the cli to use a large amount of memory? Suddenly having to increase memory after a minor version bump is a bit concerning to me.

If this is to be the accepted norm I would be happy to put together a PR to document it so others don't think something is wrong, but would like confirmation from someone like @filipesilva first.

This solution does not work for containers like travis..

Working on a large application i simply can't build anymore with AOT even increasing the memory to 5g..

I really appreciate your great work on Angular so far, but I have to say that it worries me that every minor update lately basically causes another error that crashes our production build and thus throttles our entire development process. Having said that, we're still dealing with the described problem as well...

I have the same issue when using --stats. Note: I have to use Typescript 2.6.1 because despite the warnings, Angular and Rx do not build with anything less than 2.5.0 (there are other open issues).
image

Same issue with a medium-large application when trying to upgrade to angular cli 1.5.0 and angular 5.0.0.

Also having same issue since upgrading to angular cli 1.5.0 and angular 5.0.0.

Heya, I'm closing this issue in favor of https://github.com/angular/angular-cli/issues/5618, but want to highlight that I'm investigating it right now. I'd appreciate it if you could read my comment in https://github.com/angular/angular-cli/issues/5618#issuecomment-343244854 and answer the questions there. It will help get to the problem of the issue in 15..

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings