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

Out of memory after upgrade to latest version #27633

Open
1 task done
fmancuso opened this issue May 13, 2024 · 7 comments
Open
1 task done

Out of memory after upgrade to latest version #27633

fmancuso opened this issue May 13, 2024 · 7 comments
Labels
needs: more info Reporter must clarify the issue

Comments

@fmancuso
Copy link

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

@alan-agius4
Copy link
Collaborator

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

@alan-agius4 alan-agius4 added the needs: more info Reporter must clarify the issue label May 13, 2024
@fmancuso
Copy link
Author

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

@fmancuso
Copy link
Author

fmancuso commented May 13, 2024

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

@rlindgren
Copy link

+1 Here for this as well

@jpike88
Copy link

jpike88 commented May 20, 2024

I've noticed builds are slower and it's more memory hungry too, multiple reloads over time cause heavy memory pressure. the Facebook team is rewriting the react compiler in rust, maybe it's time to consider doing the same here... I am using biomejs instead of eslint and the difference in memory/cpu usage was dramatic.

@ZissisT
Copy link

ZissisT commented May 30, 2024

This happens to me when no package-lock.json. Did you update npm as well?
npm/cli#7276

Edit: Sorry for any confusion, I get the same out of memory error during npm install, not building, so ignore my comment

@fmancuso
Copy link
Author

fmancuso commented May 30, 2024

In my case it turned out to be a problem due to the change from node-sass to sass. I had to replace a lot of the @import with @use as suggested by sass, the amount of RAM has decreased a lot, it still continues to be slower than before the upgrade. Before the upgrade the build went up to a maximum of 4gb now it goes up to 5.5gb in fact I had to pass the option --max-old-space-size=8192 to avoid problem. In any case I would investigate why there is this increase in RAM required.

I hope it can be useful to someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests

5 participants