angular/angular-cli

Out of memory after upgrade to latest version

fmancuso opened this issue · 7 comments

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

12

Description

After upgrading from angular 12 to angular 17 the build command started to go in Out of memory.

Minimal Reproduction

I cannot provide a minimal reproduction as I would have to upload my entire project.

Exception or Error

I tried to build with a --max-old-space-size=12000 and there is the log after the OOM error:
<--- Last few GCs --->

[69393:0x7feef0100000]   214299 ms: Mark-Compact 11821.8 (12037.0) -> 11819.9 (12036.0) MB, 4539.15 / 0.00 ms  (average mu = 0.277, current mu = 0.034) allocation failure; scavenge might not succeed
[69393:0x7feef0100000]   220253 ms: Mark-Compact 11835.7 (12036.0) -> 11833.9 (12066.0) MB, 5930.46 / 0.00 ms  (average mu = 0.139, current mu = 0.004) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1052b5b15 node::Abort() [/Users/francesco.mancuso/.nvm/versions/node/v20.9.0/bin/node]
 2: 0x1052b5cf6 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/Users/francesco.mancuso/.nvm/versions/node/v20.9.0/bin/node]
 3: 0x105468d6c v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/Users/francesco.mancuso/.nvm/versions/node/v20.9.0/bin/node]
 4: 0x105658e07 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/francesco.mancuso/.nvm/versions/node/v20.9.0/bin/node]
 5: 0x105657669 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/francesco.mancuso/.nvm/versions/node/v20.9.0/bin/node]
 6: 0x10564bed1 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/francesco.mancuso/.nvm/versions/node/v20.9.0/bin/node]
 7: 0x10564c915 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/francesco.mancuso/.nvm/versions/node/v20.9.0/bin/node]
 8: 0x10562ea02 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/francesco.mancuso/.nvm/versions/node/v20.9.0/bin/node]
 9: 0x105aac5e0 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/francesco.mancuso/.nvm/versions/node/v20.9.0/bin/node]
10: 0x68d39a536
11: 0x68d33dd72.

Your Environment

Previous versions:
Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1200.4
@angular-devkit/build-angular      0.1000.5
@angular-devkit/build-ng-packagr   0.1000.5
@angular-devkit/core               12.0.4
@angular-devkit/schematics         12.0.4
@schematics/angular                12.0.4
ng-packagr                         10.0.3
rxjs                               6.5.5
typescript                         4.2.3
zone.js                               0.10.3

Actual version:
@angular-devkit/architect       0.1703.7
@angular-devkit/build-angular   17.3.7
@angular-devkit/core            17.3.7
@angular-devkit/schematics      17.3.7
@angular/cli                    17.3.7
@schematics/angular             17.3.7
ng-packagr                      17.3.0
rxjs                            7.4.0
typescript                      5.3.3
zone.js                         0.14.5

Anything else relevant?

The components and the various file in the project are the same.
Previous the upgrade the maximum quantity of RAM that the process took up was 4 GB now it grows without limits.
I tried to take a memory heap dump but without success as the dump was getting stuck

Unforunyley without a memory snapshot there is nothing that we can inveiagte, ou can generate a memory snapshot by uisig the below command.

node --heapsnapshot-near-heap-limit=1 node_modules/@angular/cli/lib/init.js build

I tried with the node options to create heap snapshot but it create an empty file

After 2 hours the empty file became a 5GB file, you can find it here: https://drive.google.com/file/d/1lpiqn4R6q7o3BIAix8LtlsFYW8n_QKJx/view?usp=drive_link

Edit:
I tried to open the heap snapshot but it gave me error.
I tried running the command:
node --heap-prof node_modules/@angular/cli/lib/init.js build
and I attach the generated .heapprofiles here:
Heapprofile.zip