Skip to content
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

serve crashes randomly after upgrading to Angular 12 #20801

Closed
1 of 15 tasks
glued opened this issue May 14, 2021 · 112 comments
Closed
1 of 15 tasks

serve crashes randomly after upgrading to Angular 12 #20801

glued opened this issue May 14, 2021 · 112 comments
Labels

Comments

@glued
Copy link

glued commented May 14, 2021

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

yes, did not see this issue in Angular 10 or 11

Description

While running ng serve for a few hours it will randomly crash with an error. When I upgraded to angular 12, I also upgraded to node 14.17.0

A clear and concise description of the problem...

🔬 Minimal Reproduction

see above

🔥 Exception or Error



FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1013024b5 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x1000b1919 node::Abort() [/usr/local/bin/node]
 3: 0x1000b1a7f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x1001f5bb7 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x1001f5b53 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 6: 0x1003a2ed5 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 7: 0x1003a497a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 8: 0x1003a00a5 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0x10039d9d0 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
10: 0x1003ac0da v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x1003ac161 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
12: 0x1003753be v8::internal::FactoryBase::NewRawTwoByteString(int, v8::internal::AllocationType) [/usr/local/bin/node]
13: 0x10060bd5f v8::internal::String::SlowFlatten(v8::internal::Isolate*, v8::internal::Handle, v8::internal::AllocationType) [/usr/local/bin/node]
14: 0x10073b507 v8::internal::Runtime_StringCharCodeAt(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
15: 0x100a80639 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
16: 0x3f2f450ab47
17: 0x3f2f452f014
Abort trap: 6

🌍 Your Environment


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 12.0.0
Node: 14.17.0
Package Manager: npm 6.14.13
OS: darwin x64

Angular: 12.0.0
... animations, cli, common, compiler, compiler-cli, core
... elements, forms, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1200.0
@angular-devkit/build-angular   12.0.0
@angular-devkit/core            12.0.0
@angular-devkit/schematics      12.0.0
@angular/cdk                    10.2.7
@angular/fire                   6.1.4
@angular/material               10.2.7
@schematics/angular             12.0.0
ng-packagr                      12.0.0
rxjs                            6.6.7
typescript                      4.2.4

Anything else relevant?

@alan-agius4
Copy link
Collaborator

Hi @glued,

Can you kindly share your project (even privately) or heap snapshots?, Unfortunately, without any addition information we will not be able to look into this issue.

@alan-agius4 alan-agius4 added the needs: more info Reporter must clarify the issue label May 17, 2021
@alan-agius4
Copy link
Collaborator

Couple of questions to can further help us.

  • Are you using HMR?
  • Are you using named chunks?

@anton-white
Copy link

@alan-agius4, thanks for the direction.

But I do really feel the build time issue relates to this one and vice versa.

Here is the error ng serve fails randomly with:

⠴ Generating browser application bundles (phase: building)...
<--- Last few GCs --->

[58819:0x102d61000]  9811769 ms: Scavenge 2032.2 (2052.4) -> 2031.6 (2052.4) MB, 251.4 / 0.0 ms  (average mu = 0.221, current mu = 0.136) allocation failure 
[58819:0x102d61000]  9811787 ms: Scavenge 2032.4 (2052.4) -> 2031.7 (2052.4) MB, 14.4 / 0.0 ms  (average mu = 0.221, current mu = 0.136) allocation failure 
[58819:0x102d61000]  9812638 ms: Mark-sweep 2032.6 (2052.6) -> 2031.6 (2052.6) MB, 845.2 / 0.0 ms  (average mu = 0.243, current mu = 0.271) allocation failure scavenge might not succeed


<--- JS stacktrace --->

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

    0: ExitFrame [pc: 0x1009dcb79]
    1: StubFrame [pc: 0x100a46574]
Security context: 0x0ceb671008d1 <JSObject>
    2: /* anonymous */(aka /* anonymous */) [0xcebd79906d1] [.../node_modules/webpack/lib/NormalModuleFactory.js:1] [bytecode=0xceb9482b759 offset=0](this=0x0cebab9c04b1 <undefined>,0x0ceb3b432869 <Object map = 0xceb1a889859>,0x0ceb272e61b9 <JSFunction (sfi = 0xcebfec50c51)>)
    3: /* anonymo...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1011d1c65 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x10009f919 node::Abort() [/usr/local/bin/node]
 3: 0x10009fa7f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x1001e3867 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x1001e3807 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 6: 0x10036b995 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 7: 0x10036d20a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 8: 0x100369c3c v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0x100367a3e v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
10: 0x10037390a v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x100373991 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
12: 0x10034135a v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
13: 0x100693768 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
14: 0x1009dcb79 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
15: 0x100a46574 Builtins_CreateFunctionContextHandler [/usr/local/bin/node]
16: 0x100962524 Builtins_InterpreterEntryTrampoline [/usr/local/bin/node]
17: 0x100962524 Builtins_InterpreterEntryTrampoline [/usr/local/bin/node]
error Command failed with signal "SIGABRT".

@anton-white
Copy link

Also I just tried to compare the memory size allocated for v11 and for v12 ng serve.

v11 gets ~600 Mb of memory and doesn't get increased on each rebuild.

v12 starts with almost 1.5 Gb and increases each time rebuild happens.

I guess when the memory allocation hits some limit the error occurs.

@alan-agius4
Copy link
Collaborator

alan-agius4 commented May 17, 2021

Also I just tried to compare the memory size allocated for v11 and for v12 ng serve.

v11 gets ~600 Mb of memory and doesn't get increased on each rebuild.

v12 starts with almost 1.5 Gb and increases each time rebuild happens.

I guess when the memory allocation hits some limit the error occurs.

Can you try to use NG_BUILD_CACHE=0 environment variable to disable Webpacks' caching?

@anton-white
Copy link

v12 versioning:

Angular CLI: 12.0.0
Node: 12.18.3
Package Manager: yarn 1.22.5
OS: darwin x64

Angular: 12.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, localize, material
... platform-browser, platform-browser-dynamic, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1200.0
@angular-devkit/build-angular   12.0.0
@angular-devkit/core            12.0.0
@angular-devkit/schematics      12.0.0
@angular/flex-layout            11.0.0-beta.33
@schematics/angular             12.0.0
rxjs                            6.6.7
typescript                      4.2.4

v11 versioning:

Angular CLI: 11.2.11
Node: 12.18.3
OS: darwin x64

Angular: 11.2.12
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.11
@angular-devkit/build-angular   0.1102.11
@angular-devkit/core            11.2.11
@angular-devkit/schematics      8.3.23
@angular/cdk                    11.2.11
@angular/cli                    11.2.11
@angular/material               11.2.11
@schematics/angular             11.2.11
@schematics/update              0.1102.11
rxjs                            6.6.3
typescript                      4.0.5

@anton-white
Copy link

Can you try to use NG_BUILD_CACHE=0 environment variable to disable Webpacks' caching?

Tried that.
It started with slightly less memory of around 1.25 Gb but grew up quickly after few rebuilds to 1.6 Gb

@sha-N
Copy link

sha-N commented May 17, 2021

@anton-white yes I can attest to that, same happened to me, compiler is randomly exceeding the memory usage than default max of NodeJs. My temp fix was to increase the max memory for node. But still it is taking a long time for compilation.

@alan-agius4 it is same situation when named chunk is true or false in the config.

Memory usage is around 4-5GB.

@sha-N
Copy link

sha-N commented May 17, 2021

@anton-white are you using angular material theming?

for me compile time issue was because of the following lines

@use '~@angular/material' as mat;
@import "~@angular/material/theming";

ng update added the @use but kept second line. After removing that (angular/components#22676 (comment)) compile time has improved by a lot. memory usage is still high.

@anton-white
Copy link

@sha-N
yes, Angular Material is being used.
But I don't have the redundant @import line.
Had to rollback to v11 for now.

@glued
Copy link
Author

glued commented May 17, 2021

Are you using HMR?

NO

Are you using named chunks?

YES ( in dev env )

@alan-agius4
Copy link
Collaborator

I spent some times looking into a project that does show OOM issues during rebuilds. The project in question was provided by @ganySA privately. (Thanks a lot for this).

What I found out from my investigation on the mentioned project is;

  • A non incremental build uses around ~1.7/1.8Gb of memory
  • After the first rebuild this increases to ~1.9/2Gb and keep in this range after multiple rebuilds
  • Disabling Webpack 5 memory caching does keep the memory usage consistent between the first and second build
  • The OOM happens when a re-build is triggered before GC kicks in a frees up the memory
  • Reverting the project to Webpack 4 used the same amount of memory that Webpack 5 uses when caching is disabled

To sum it up, from the project I look at, it doesn't appear that there is a memory leak as memory usage stays within the same range over a number of rebuilds but rather the increase in memory usage is to be attributed to Webpack 5 caching.

Note: there are number of options such as outputHashing being enabled and namedChunks being disabled can contribute to a memory leak when used in watch mode.

That said, without a reproduction even shared privately or memory snapshots, we will not be able to determine if there is a memory leak, or it's just the expected increase of memory usage due to Webpack 5 caching, in the upcoming release we also shifted SASS to be processed in workers which should help reduce memory pressure on the main thread since workers have a dedicated memory pool.

@amitagt007
Copy link

while upgrading from angular 11 to 12, the in the angular .json file, the aot flag updated to false, with this value ng serve is working perfectly but while running ng test command its thworing the "Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory". If only one test file is run , then it succeeds -> any help to fix this up?

@cesco69
Copy link

cesco69 commented May 19, 2021

@alan-agius4 How can produce a memory snapshot of ng serve for help to solve this issue?

@cesco69
Copy link

cesco69 commented May 19, 2021

The workaround I have found is run ng serve in this way:

node --max-old-space-size=4096 ./node_modules/@angular/cli/bin/ng serve

otherwise node crash

@alan-agius4
Copy link
Collaborator

@alan-agius4 How can produce a memory snapshot of ng serve for help to solve this issue?

  1. node --inspect-brk node_modules/@angular/cli/lib/init.js serve
  2. Open Chrome and type chrome://inspect in the address bar
  3. Click on the inspect button from one of your applications in the Remote Target section.
  4. Go to Chrome DevTools > Memory
  5. Take a heap snapshot
  6. Perform the action that causes OOM

Repeat the last 2 until the OOM error is shown, once done, save the last couple of snapshots and send them over.

@amitagt007
Copy link

I tried installing 64bit node and it worked fine and resolved my issue.

@cesco69
Copy link

cesco69 commented May 19, 2021

@alan-agius4 I have send the memory snapshots at your e-mail

@leonelvsc
Copy link

leonelvsc commented May 20, 2021

In my case disabling styles optimizations in angular.json makes the build work again without crashing out of memory i have 32gb of RAM and compiling with --max-old-space-size=12288 makes the build crash.

One important thing that i've noticed is that the build start crashing after upgrading from project clarity 4 -> 5, i'm assuming that the build is crashing because of some bug on css processing libraries with "modern css"

@alan-agius4
Copy link
Collaborator

In my case disabling styles optimizations in angular.json makes the build work again without crashing out of memory i have 32gb of RAM and compiling with --max-old-space-size=12288 makes the build crash.

One important thing that i've noticed is that the build start crashing after upgrading from project clarity 4 -> 5, i'm assuming that the build is crashing because of some bug on css processing libraries with "modern css"

Why would you have optimizations enabled during ng serve?

@leonelvsc
Copy link

leonelvsc commented May 20, 2021

In my case disabling styles optimizations in angular.json makes the build work again without crashing out of memory i have 32gb of RAM and compiling with --max-old-space-size=12288 makes the build crash.
One important thing that i've noticed is that the build start crashing after upgrading from project clarity 4 -> 5, i'm assuming that the build is crashing because of some bug on css processing libraries with "modern css"

Why would you have optimizations enabled during ng serve?

Sorry my english is bad..

I get the same error, but i forgot to mention that the error happens only in ng build --configuration production i've disabled those optimizations in the "production" config

@alan-agius4
Copy link
Collaborator

Yesterday release (12.0.1) contains several performance improvements. Please give it a try!

@glaanc03

This comment has been minimized.

@pette9

This comment has been minimized.

@keyanan-x
Copy link

keyanan-x commented Aug 11, 2021 via email

@glapenta
Copy link

Updated to 12.2.0, it seems better now.

@weilinzung
Copy link

CLI on 12.2.0 still has the same issue, and even with --max_old-space-size=12000.

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.2
@angular-devkit/build-angular   12.1.4
@angular-devkit/core            12.2.0
@angular-devkit/schematics      12.2.0
@angular/compiler-cli           12.1.5
@angular/fire                   6.1.4
@angular/language-service       12.1.5
@schematics/angular             11.0.1
ng-packagr                      12.1.1
rxjs                            6.6.7
typescript                      4.2.4
webpack                         5.42.0
    "@angular/animations": "^12.1.3",
    "@angular/cdk": "^12.1.3",
    "@angular/common": "^12.1.3",
    "@angular/compiler": "^12.1.3",
    "@angular/core": "^12.1.3",
    "@angular/fire": "^6.1.4",
    "@angular/forms": "^12.1.3",
    "@angular/google-maps": "^12.1.3",
    "@angular/material": "^12.1.3",
    "@angular/material-moment-adapter": "^12.1.3",
    "@angular/platform-browser": "^12.1.3",
    "@angular/platform-browser-dynamic": "^12.1.3",
    "@angular/router": "^12.1.3",
...
<--- Last few GCs --->

[23402:0x104909000] 17212286 ms: Scavenge (reduce) 11919.6 (12022.0) -> 11918.7 (12023.0) MB, 11.4 / 0.0 ms  (average mu = 0.085, current mu = 0.060) allocation failure
[23402:0x104909000] 17212317 ms: Scavenge (reduce) 11919.7 (12022.0) -> 11918.9 (12023.0) MB, 10.9 / 0.0 ms  (average mu = 0.085, current mu = 0.060) allocation failure
[23402:0x104909000] 17212338 ms: Scavenge (reduce) 11919.7 (12022.0) -> 11919.0 (12023.0) MB, 14.6 / 0.0 ms  (average mu = 0.085, current mu = 0.060) allocation failure


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x101317585 node::Abort() (.cold.1) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
 2: 0x1000b25c9 node::Abort() [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
 3: 0x1000b272f node::OnFatalError(char const*, char const*) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
 4: 0x1001f6eb7 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
 5: 0x1001f6e53 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
 6: 0x1003a6eb5 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
 7: 0x1003a897a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
 8: 0x1003a4049 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
 9: 0x1003a18e1 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
10: 0x1003b019a v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
11: 0x1003b0221 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
12: 0x100380160 v8::internal::Factory::NewProperSubString(v8::internal::Handle<v8::internal::String>, int, int) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
13: 0x100725fc1 v8::internal::Runtime_StringSplit(int, unsigned long*, v8::internal::Isolate*) [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
14: 0x100a8a919 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
15: 0x100a7c5bf Builtins_StringPrototypeSplit [/Users/iam/.nvm/versions/node/v14.17.3/bin/node]
16: 0x93a5d85afe

@alan-agius4
Copy link
Collaborator

@weilinzung, please provide memory snapshots otherwise we cannot investigate this issue.

@clydin
Copy link
Member

clydin commented Sep 21, 2021

@weilinzung From the version output, the project appears to contain packages with a mixture of Angular versions (including two different majors): 12.1.2, 12.1.4, 12.2.0, 12.1.5, 11.0.1.
In addition, @angular-devkit/build-angular contains the majority of the build processing pipeline and appears to still be on version 12.1.4.
If possible please try to synchronize the versions within the project's package.json. Removing the package lock file may also be useful in this regard.

@tlaverdure
Copy link

tlaverdure commented Sep 30, 2021

@alan-agius4 I've been running into this issue as well. I've attached some memory snapshots. At the point where the process ran out of memory it was using 4GB of memory.

Angular CLI: 12.2.2
Node: 16.7.0 (Unsupported)
Package Manager: npm 7.20.3
OS: darwin x64

Angular: 12.2.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, platform-browser
... platform-browser-dynamic, platform-server, pwa, router
... service-worker

Package Version

@angular-devkit/architect 0.1201.4
@angular-devkit/build-angular 12.2.2
@angular-devkit/core 12.2.2
@angular-devkit/schematics 12.2.2
@nguniversal/builders 12.1.0
@nguniversal/express-engine 12.1.0
@schematics/angular 12.2.2
ng-packagr 12.0.5
rxjs 6.6.3
typescript 4.2.4

Archive.zip

@trongrg
Copy link

trongrg commented Oct 11, 2021

I'm getting this issue to the point I can't develop the application anymore, it keeps crashing every 10 mins. Initial build is 1.6GB, and subsequence build increase it by hundred MB

Steps to reproduce is pretty easy: ng serve, and then open an editor and keep pressing save repeatedly without any changes

However I just got this recently so I will try to track down the cause

@trongrg
Copy link

trongrg commented Oct 11, 2021

I think for me the issue was with country-state-city package, removing it makes the serve process back to normal. It seems to be the json import

Angular CLI: 12.2.9
Node: 14.17.6
Package Manager: npm 6.14.15
OS: darwin x64

Angular: 12.2.9
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.1200.5
@angular-devkit/build-angular 12.2.9
@angular-devkit/core 12.2.9
@angular-devkit/schematics 12.2.9
@schematics/angular 12.2.9
rxjs 6.6.7
typescript 4.2.4

https://drive.google.com/file/d/1YKEG_e4gqC6q7jFVKKb0uY6R6O4smL9b/view?usp=sharing

@oguimbal
Copy link

FYI for us, removing an heavy css import fixed the problem.

We were including a ~1MB+ stylesheet in one of our .scss file... which started to trigger this issue after upgrading to Angular 12.
We circumvented that by including it directly in index.html.
That's a bit dirty, but at least it seems to have made Angular usable again.

@EDGESoftware
Copy link

From #22020
Hi Alan,

Thx for pointing me to #20801. I've spent the last week studying that and was unable to figure out how to get a heap snapshot when triggering a build (serve) from VS Code. However, I have come up with a workaround/hack(?) that seems to solve my problem. If I issue the following in a newly opened PowerShell console in VS Code I am able to avoid the heap OOM on my rebuilds (re-serves):
$env:NODE_OPTIONS = '--max-old-space-size=4096'
npx nx serve my-app --poll=2000 --progress

It looks like VS Code ignores a globally set environment variable so I have to set it in the same process where the build occurs. That' interesting because "dir env:" shows that all of the other global environment variables have been inherited - just not NODE_OPTIONS.

I have no idea if I just needed some additional memory or if there is still a bug but I just haven't done enough rebuilds(re-serves) to trigger it again.

Any ideas/comments?

Thx,
Al

@Akxe
Copy link

Akxe commented Nov 8, 2021

I have just updated to nx 13.1.3 and Angular 12.x.x and my server build crashes! I do usually run the server with the command nx serve server and now it crashes after every change. Do nx team still need reproduction repositories?

Additional info: Due to upgrading problems I removed node_modules and package_lock prior install. Thus it is a pretty clean repository now.


19.11.2021:

Updated to nx v13.2.0 and angular v~13.0.0, the error is still there. (Also npm was not able to update, had to use yarn)

@kyxyes
Copy link

kyxyes commented Dec 7, 2021

Getting this error with Angular v13.2, was on v11+ and no issue before
#13 127.1 runtime: out of memory: cannot allocate 809500672-byte block (3329949696 in use) #13 127.1 fatal error: out of memory #13 127.1 #13 127.1 goroutine 10 [running]: #13 127.1 runtime.throw({0x7c187, 0xd})

@SDAdham
Copy link

SDAdham commented Jan 22, 2022

I upgraded to Angular 13.1.3 hoping that this issue would go away, but it's still there :(

@rppig42
Copy link

rppig42 commented Jan 25, 2022

Upgraded from 11.1.2 to 13.1.1 and this issue emerges.

I can reproduce this issue every time when I use a second terminal to run ng build

@Akxe
Copy link

Akxe commented Feb 1, 2022

Sadly this is not an issue with Angular, but with Webpack: webpack/webpack#12771

I used to crash after every change, but after minifying (any simplifying) JSON files from 500Mb to 50Mb, the crashes are gone. So my suggestion is to look for large imported files and try not to import them if possible.

@SDAdham
Copy link

SDAdham commented Feb 5, 2022

I don't have large files in angular. It just consumes up to 2.9 gb and during build, it'd go up to 3.5 gb. I have zero idea why whould serve take that much space. The project is huge and this was pain but nothing is clear about whys here.

I had to ditch Ng serve completely and use Ng build with nodemon and angular 13. Since angular 13 caches build. This helped as a workaround with a great difference. Now angular consumes 50mb runtime and 1 gb during build.

I still wonder why build would go that much high. It's just frontend. Nestjs (backend) does tons better job than angular in this.

@SDAdham
Copy link

SDAdham commented Feb 5, 2022

Also since ditching Ng serve. It's much more stable for me. No more weird unexplained port drops or simply the serve stops for unknown reason. It's just stable for me

@pmoleri
Copy link

pmoleri commented Feb 7, 2022

@SDAdham @Akxe I had this issue in early v12 versions, but it's been working fine in both 12.2.3 and 13.1.3.
Have you checked out my previous comment?
If you migrated from a previous version (e.g. v11) your development config might be messed up. You should check all the values and how they merge with the default config.

@SDAdham
Copy link

SDAdham commented Feb 8, 2022

@pmoleri , I've got everything you mentioned in there, except sadly only "aot": true is not enabled for dynamic html rendering

@barnabasbartha
Copy link

Any update on this? 👀

@JoostK
Copy link
Member

JoostK commented Apr 2, 2022

Any update on this? 👀

Unfortunately without a reproduction this isn't really actionable.

@Akxe
Copy link

Akxe commented Apr 2, 2022

@JoostK Build an app with 100Mb JSON file, it will do the job, at least does for me. I know that because removing these from the build did remove the error.

@JoostK
Copy link
Member

JoostK commented Apr 2, 2022

@Akxe can you prepare a repo?

@Akxe
Copy link

Akxe commented Apr 2, 2022

@JoostK Not anymore actually, sorry

@alan-agius4
Copy link
Collaborator

The issue has been open for some time and a lot has changed since then. While there were several people reporting and commenting on this issue. A reproduction was not provided that demonstrates / suggests that there is a memory leak.

If you are still experiencing this issue please open a new issue and provide all necessary information including a minimal reproduction or at the very minimum memory snapshots.

@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 Jul 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests