Skip to content

1.5.0 - cannot build with AOT or Build Optimizer: JavaScript heap out of memory #8334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bniedermeyer opened this issue Nov 3, 2017 · 13 comments
Assignees
Labels
P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken

Comments

@bniedermeyer
Copy link
Contributor

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.

@bniedermeyer bniedermeyer changed the title 1.5 - cannot build with AOT or Build Optimizer: JavaScript heap out of memory 1.5.0 - cannot build with AOT or Build Optimizer: JavaScript heap out of memory Nov 3, 2017
@btroncone
Copy link
Contributor

I'm having the same issue since 1.5

@ronsc
Copy link

ronsc commented Nov 4, 2017

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.

@williangd
Copy link

Same problema since 1.3 :(

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

@ronsc
Copy link

ronsc commented Nov 6, 2017

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

@bniedermeyer
Copy link
Contributor Author

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.

@AmitMY
Copy link
Contributor

AmitMY commented Nov 7, 2017

This solution does not work for containers like travis..

@PillowPillow
Copy link

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

@rbluethl
Copy link

rbluethl commented Nov 8, 2017

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...

@raysuelzer
Copy link

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

@ellesse
Copy link

ellesse commented Nov 8, 2017

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

@damiandennis
Copy link

damiandennis commented Nov 9, 2017

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

@Brocco Brocco added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken labels Nov 10, 2017
@Brocco Brocco assigned filipesilva and unassigned hansl Nov 10, 2017
@filipesilva
Copy link
Contributor

Heya, I'm closing this issue in favor of #5618, but want to highlight that I'm investigating it right now. I'd appreciate it if you could read my comment in #5618 (comment) and answer the questions there. It will help get to the problem of the issue in 15..

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken
Projects
None yet
Development

No branches or pull requests