-
Notifications
You must be signed in to change notification settings - Fork 12k
ng build fail with 'JavaScript heap out of memory' with patch 6.0.3 #10897
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
Comments
I experience the same issue in some kind: Angular CLI: 6.0.3
Node: 9.2.0
OS: linux x64
Angular: 6.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.6.1
@angular-devkit/build-angular 0.6.1
@angular-devkit/build-optimizer 0.6.1
@angular-devkit/core 0.6.3
@angular-devkit/schematics 0.6.3
@angular/cdk 6.0.2
@angular/cli 6.0.3
@angular/flex-layout 6.0.0-beta.15
@angular/material 6.0.2
@angular/material-moment-adapter 6.0.2
@ngtools/webpack 6.0.1
@schematics/angular 0.6.3
@schematics/update 0.6.3
rxjs 6.1.0
typescript 2.7.2
webpack 4.8.3 The command to build: node --max_old_space_size=12000 ./node_modules/.bin/ng build --configuration=$ENV \
--prod --source-map=$useSourceMaps \
--i18nFile=src/locale/messages.$lang.xtb \
--i18nFormat=xtb \
--i18n-locale=$locale \
--baseHref=/$lang/ \
--outputPath=dist/$ENV/$lang \
--deployUrl=$deployUrl/$lang I assigned a lot of memory but it hangs at building 67%.. Also I saw using it up to 10GB of RAM when manually monitoring with htop.. This is not very accurate ofcourse but indicates a problem if you ask me. This issue makes it impossible to deploy... Is there a downgrade guide back to angular 5 or did I end up in a new angular "adventure"? |
Can you try with node v10? There are known nodeJS performance issues with Map/Set (used heavily within webpack internally) in versions higher than v8.9.4 and less then v10. |
A part of my issue seems related to #9779 Also installing v10 doesnt make a difference. Downgrading to angular 5 again.
|
After few tests I downgrade to 6.0.0 and set sourceMap to false. And in fact upgrading to node 10 helped, but I still see a 2x to 3x times increase in build time between 6.0.0 and 6.0.1. |
Same issue here: after upgrading Angular from v5.2.8 to v6.0.3 production bundle (aot, unminified) build time/peak memory usage changed from Here is the
We're using custom webpack configuration with |
@th0r Can you try with webpack 4.6? |
@clydin same out of memory error with Webpack 4.6. |
@clydin by the way I used Node v8.11.2. After upgrading to Node v10.1.0 results are |
@th0r That's good to hear at least the build time is better. Is that with webpack 4.6 or 4.8.3? |
This is with webpack 4.8.3. Downgrading to 4.6.0 doesn't reduce memory consumption. |
@th0r can you also try with Build Optimizer turned off in CLI 1.x versus 6.x please? |
How can I turn if off? |
If the webpack config uses this loader: |
Hmm, I didn't know it exists, so it wasn't turned on 😉 |
@clydin could you point to the line in |
We do it here for general JS files https://github.com/angular/devkit/blob/0be99d3e3f5bc96ea57fd72b835ca83f95f4fe5f/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts#L162-L182 And here for application files https://github.com/angular/devkit/blob/0be99d3e3f5bc96ea57fd72b835ca83f95f4fe5f/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/typescript.ts#L98-L103 But it will only make it slower if you don't use it already. Makes for smaller bundles though. |
Also, did I think the change might be unrelated to either Angular or ngtools/webpack. Probably only one of those is affecting things. If you use the 1.x ngtools/webpack, do you get the lower memory usage? |
@filipesilva |
That's... odd.... so it sounds like the increased memory usage was due to updating Angular libraries (outside of Angular CLI)? |
Here is the |
Maybe it's somehow related to update of |
I wouldn't expect that, but maybe. I'll be doing some performance benchmarking soon and be sure to keep an eye out on the memory usage. |
@filipesilva I've found an issue...but I don't have words... I can't believe it! I didn't even include it in the diff I posted above because I thought it doesn't matter at all! WTF?! My only assumption is that they added a few recursive types like PartialDeep that consume a lot of memory but I'm not sure about anything in this world anymore. |
Well that's odd. But also interesting. Can you give me the lodash before and after versions? Maybe we can come up with a simple repro and pinpoint the problem. A lot of people might be suffering from this. Used lodash imports would also be useful. |
You can find before/after versions in the comment above. We import the whole lodash and use quite a lot of it's methods including |
@filipesilva to summ up: Node.js v10.1.0 with
Without
P.S. |
But what if you need source-maps in your prod build - what to do? |
@dauledk i would recommend to downgrade the cli to a version where build works. |
Hi @stefan-karlsson. Could you point what cli version is working for u. |
My solution was to explicitly specify in the tsconfig.ts |
Hi all, Are you still seeing this with the latest versions? Does anyone have some up to date reproduction instructions that I can follow to see it too? |
@filipesilva our project has grown a little and here are the latest results:
Build (sourcemaps off, minimizer off):
So I can't see any progress here. |
@th0r it is expected that at some point you need to increase the memory limit. That is not a bug. Larger projects will need more resources to build. Since NodeJS projects have a default memory limit, it will be reached at some point. One can argue that the current memory usage is too high. I wouldn't say that 2 minutes to build a project for production is too long though. I wouldn't even say 2mins to build a large project for development is too long, as long as rebuilds are short. I don't know the specifics of your project, but please bear in mind that it's not all just your source code. You might not have a huge amount of source TS files but still have a lot of code in imported libraries. |
But it's not for production - both sourcemaps and minification are turned off. If I turn them on stats become 4.6 mins / ~5gb mem at peak. I think 5gb of ram is a little bit too much. |
I noticed this as well after |
bump |
@filipesilva @th0r I have a similar issue, I am using angular cli build with tfs build pipeline. I use ng build --prod and the encounter the FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory. I know i have to increase the memory size, I am unsure how to do it. if i perform from cmd: How do i correctly set the max_old_space_size as a global value and use ng build --prod or execute npm run ? using: Tried updating node to v 10.15.3 but the build times are same. |
@gnagakarthik I use custom build configuration instead of Seems like you can set it via NODE_OPTIONS env variable. |
I run since a few day's also in this issue and done my workaround as follow:
It works actually fine for my usage with the default ng server/build process. I hope not to run in it soon again... |
To git raid of this issue add this
and now run |
Even after assigning 8gigs, my build still fails. Sourcemap is false as well. This didn't happen when I was on ng5, after ng7, it broke altogether. I cannot even run webpack stats to see what is taking up so much data.. |
Increase maximum memory allocated for budgets in angular.json "budgets": [ and used this command |
We are seeing this on dev builds as well. We used ionic to create or project and it uses architect. I am wondering if this has something to do with architect not managing memory correctly. Maybe file copies as we have a lot of assets that architect is copying. Also, we were not seeing this issue under ng 5 before the migration to ng7 |
Upgraded to Angular 8.1 from 7.2.15. Solved by increasing the Node memory limit from the default 1.5GB to 2.0GB. |
I'm getting this message with cli 8.2.1: adding --max_old_space_size=8000 didn't help "@angular-devkit/build-webpack": "^0.802.1", thoughts? |
We have been seeing memory problem on Angular CLI 8 and work has been tracked in #13734. I'll close this issue in favor of that one. Please check out the comments there, especially #13734 (comment). |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions
Repro steps
ng build --prod
Observed behavior
92% chunk asset optimization UglifyJSPlugin
[.. waiting for long time]
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Desired behavior
Build works
Mention any other details that might be useful (optional)
Back to 6.0.1 and 0.6.1 like few days ago works. For the moment I didn't change the default memory allocate to node.
The text was updated successfully, but these errors were encountered: