You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
Hello,
The build command I run for my project is :
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --configuration production
This commands runs successfully, but however the NodeJS process for building app takes up to 10GB.
To be more precise, during beginning-middle of building phase it takes less than 4GB,
and always at the middle-end of building phase, it goes up to 10GB just before end of successful build.
To start investigation, I launched build command with "-trace-gc" option :
node --trace-gc --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --configuration production
I saw, with this option, that there are several Node "V8 isolates" that are created in the same NodeJS process ("V8 isolate" = JS Heap instance, based on Node GC documentation) :
Among those "V8 isolates", with a proper heap for each, 2 of them have particular high heap amount at the same time :
The main one (Instance : 0000022555190EE0) goes up to 3.3 GB of heap
A another one (Instance : 0000022662E89020), created at middle-end of build phase, goes up to 4GB
What also have to be noticed is that the second one consumes such a memory ONLY when option "production > optimization > scripts" in "angular.json" is set to true.
The "production > optimization > scripts" option in "angular.json" is required for my production performance requirements (minification, tree-shaking, dead-code elimination).
So my questions/remarks are :
The "max_old_space_size" parameter seems to mainly apply to the MAIN V8 isolate, so I'm not able to configure "global" memory consumption during build phase. Is there a parameter to configure the GLOBAL heap used by NodeJS process for building phase ? If not, I think it could be useful to have one, and/or be able to fine-tune memory for all V8 isolates with high memory consumption
I cannot find any documentation explaning the fact that "production > optimization > scripts" option can result in high memory consumption, why it takes such memory, how I could tune it. Is is possible to have such a documentation / explanation ?
The "max_old_space_size" parameter seems to mainly apply to the MAIN V8 isolate, so I'm not able to configure "global" memory consumption during build phase. Is there a parameter to configure the GLOBAL heap used by NodeJS process for building phase ? If not, I think it could be useful to have one, and/or be able to fine-tune memory for all V8 isolates with high memory consumption
No, Node.js does not provide a global way of doing so. What you can do however is use NG_BUILD_MAX_WORKERS to reduce the number of workers used at the cost of increasing the build time.
I cannot find any documentation explaning the fact that "production > optimization > scripts" option can result in high memory consumption, why it takes such memory, how I could tune it. Is is possible to have such a documentation / explanation ?
This is expected when using the Webpack and terser build pipeline, three-shaking and dead code elimination are resource intensive tasks that lead to increased in memory and CPU usage. There are no settings to fine-tune this or reduce the memory usage.
I also found this issue about memory limits for several "V8 isolates" in NodeJS, and was wondering whether it could be linked to my issue : nodejs/node#43991
No really, as that issues mentions that max_old_space_size is overridding the resourceLimits.maxOldSpaceSizeMb that is passed to each worker which we do not use.
I am not seeing anything that is actionable from our end here.
Command
build
Is this a regression?
The previous version in which this bug was not present was
No response
Description
Hello,
The build command I run for my project is :
This commands runs successfully, but however the NodeJS process for building app takes up to 10GB.
To be more precise, during beginning-middle of building phase it takes less than 4GB,
and always at the middle-end of building phase, it goes up to 10GB just before end of successful build.
To start investigation, I launched build command with "-trace-gc" option :
I saw, with this option, that there are several Node "V8 isolates" that are created in the same NodeJS process ("V8 isolate" = JS Heap instance, based on Node GC documentation) :
Among those "V8 isolates", with a proper heap for each, 2 of them have particular high heap amount at the same time :
What also have to be noticed is that the second one consumes such a memory ONLY when option "production > optimization > scripts" in "angular.json" is set to true.
The "production > optimization > scripts" option in "angular.json" is required for my production performance requirements (minification, tree-shaking, dead-code elimination).
So my questions/remarks are :
The "max_old_space_size" parameter seems to mainly apply to the MAIN V8 isolate, so I'm not able to configure "global" memory consumption during build phase. Is there a parameter to configure the GLOBAL heap used by NodeJS process for building phase ? If not, I think it could be useful to have one, and/or be able to fine-tune memory for all V8 isolates with high memory consumption
I cannot find any documentation explaning the fact that "production > optimization > scripts" option can result in high memory consumption, why it takes such memory, how I could tune it. Is is possible to have such a documentation / explanation ?
I also found this issue about memory limits for several "V8 isolates" in NodeJS, and was wondering whether it could be linked to my issue : worker: resourceLimits overridden by --max-old-space-size nodejs/node#43991
Thanks
Note : I was also facing same issue with Angular 14 :
#26553
Minimal Reproduction
Command run :
Packages :
Exception or Error
No response
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: