Closed glued closed 2 years ago
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.
Couple of questions to can further help us.
@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".
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.
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?
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
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
@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.
@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 (https://github.com/angular/components/issues/22676#issuecomment-839877758) compile time has improved by a lot. memory usage is still high.
@sha-N
yes, Angular Material is being used.
But I don't have the redundant @import
line.
Had to rollback to v11 for now.
Are you using HMR?
NO
Are you using named chunks?
YES ( in dev env )
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;
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.
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?
@alan-agius4 How can produce a memory snapshot of ng serve
for help to solve this issue?
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 How can produce a memory snapshot of
ng serve
for help to solve this issue?
node --inspect-brk node_modules/@angular/cli/lib/init.js serve
chrome://inspect
in the address barinspect
button from one of your applications in the Remote Target section.Chrome DevTools
> Memory
Repeat the last 2 until the OOM error is shown, once done, save the last couple of snapshots and send them over.
I tried installing 64bit node and it worked fine and resolved my issue.
@alan-agius4 I have send the memory snapshots at your e-mail
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"
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
?
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
Yesterday release (12.0.1) contains several performance improvements. Please give it a try!
I am encountering the same problem after the upgrade to 12.0.1 (Node.js version used is 14.17.0)
ng build -c production
results in OOM every time. ng serve
and ng test
are working fine.
I am encountering the same problem after the upgrade to 12.0.1 (Node.js version used is 14.17.0)
ng build -c production
results in OOM every time.ng serve
andng test
are working fine.
This could be related to this issue. There is already a fix in the pipeline. As a temporary fix for now, you can downgrade just the @angular-devkit/build-angular to v12.0.0 instead of v12.0.1 and retry the ng build -c production
command.
Since upgrading to Angular 12 we are getting OOM (error 137) error during CI/CD build on Azure DevOps.
We have tried the following without success:
On my Macbook 16" 2020 with 32GB of RAM i can build the app using ng build --configuration production
We built a Ubunt Linux VM with similar memory constraints as the Hosted Azure DevOps build agent and attempted a build which failed with error 137 OOM.
Regards, Tarek
I have problems like @thaoula when deployed on heroku
@vdumbrav & @thaoula, this issue is to track issues with the dev-server. The issue that you are experiencing can be found here: https://github.com/angular/angular-cli/issues/20883 and a fix will be available in 12.0.2.
A fix for the memory usage will be available in 12.0.2 which will be available this week. For a more detailed explanation of the cause, please see this comment: https://github.com/angular/angular-cli/issues/20713#issuecomment-847027235
Anyone is still experiencing this issue with ng serve
in 12.0.1
or later?
Anyone is still experiencing this issue with
ng serve
in12.0.1
or later?
Yes... after a lot of code changes it crash
Jumping in here. I am experiencing the same OOM crashes after upgrading to v12.
I am open to share privately my repo to you @alan-agius4 or anybody who could investigate the issue.
Falling back to v11 now, because ng serve
doesn't work anymore. Thanks for looking into it!
Edit: Same after latest upgrades:
Angular CLI: 12.0.2
Node: 14.16.0
Package Manager: yarn 1.22.5
OS: linux x64
Angular: 12.0.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, localize, material
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1200.1
@angular-devkit/build-angular 12.0.2
@angular-devkit/core 12.0.2
@angular-devkit/schematics 12.0.2
@angular/flex-layout 12.0.0-beta.34
@schematics/angular 12.0.2
rxjs 6.6.7
typescript 4.2.4
UPDATE UPDATE UPDATE
**Guys we solved it by using 64bit version of node. That's the issue.
Do NOT use 32bit version.**
Old comment:
Environment:
Angular CLI: 12.0.2
Node: 14.17.0
Package Manager: npm 6.14.13
OS: win32 ia32
Angular: 12.0.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, localize, material, platform-browser
... platform-browser-dynamic, router, service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1200.2
@angular-devkit/build-angular 12.0.2
@angular-devkit/core 12.0.2
@angular-devkit/schematics 12.0.2
@angular/fire 6.1.5
@schematics/angular 12.0.2
rxjs 6.5.5
typescript 4.2.4
Log:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files (x86)\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev'
1 verbose cli ]
2 info using npm@6.14.13
3 info using node@v14.17.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle admin@0.1.3~predev: admin@0.1.3
6 info lifecycle admin@0.1.3~dev: admin@0.1.3
7 verbose lifecycle admin@0.1.3~dev: unsafe-perm in lifecycle true
8 verbose lifecycle admin@0.1.3~dev: PATH: C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\prjs\Fabrik\fastorder\admin\node_modules\.bin;C:\Python39\Scripts\;C:\Python39\;C:\Python38\Scripts\;C:\Python38\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Git\cmd;C:\docker;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Yarn\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\GitExtensions\;C:\Program Files (x86)\nodejs\;C:\Users\andre\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Users\andre\AppData\Local\Microsoft\WindowsApps;C:\Users\andre\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\andre\AppData\Local\Yarn\bin;C:\Users\andre\AppData\Local\GitHubDesktop\bin;C:\Users\andre\AppData\Local\Microsoft\WindowsApps;C:\Users\andre\AppData\Roaming\npm;C:\Users\andre\AppData\Roaming\nvm;C:\Program Files\nodejs
9 verbose lifecycle admin@0.1.3~dev: CWD: C:\prjs\Fabrik\fastorder\admin
10 silly lifecycle admin@0.1.3~dev: Args: [
10 silly lifecycle '/d /s /c',
10 silly lifecycle 'ng serve --host=0.0.0.0 --port=4300 --proxy-config proxy.conf.json --configuration=en --base-href /en --open'
10 silly lifecycle ]
11 silly lifecycle admin@0.1.3~dev: Returned: code: 134 signal: null
12 info lifecycle admin@0.1.3~dev: Failed to exec dev script
13 verbose stack Error: admin@0.1.3 dev: `ng serve --host=0.0.0.0 --port=4300 --proxy-config proxy.conf.json --configuration=en --base-href /en --open`
13 verbose stack Exit status 134
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:376:20)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:376:20)
13 verbose stack at maybeClose (internal/child_process.js:1055:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid admin@0.1.3
15 verbose cwd C:\prjs\Fabrik\fastorder\admin
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v14.17.0
19 verbose npm v6.14.13
20 error code ELIFECYCLE
21 error errno 134
22 error admin@0.1.3 dev: `ng serve --host=0.0.0.0 --port=4300 --proxy-config proxy.conf.json --configuration=en --base-href /en --open`
22 error Exit status 134
23 error Failed at the admin@0.1.3 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 134, true ]
I tried installing 64bit node and it worked fine and resolved my issue.
This saved me! Thank you
UPDATE UPDATE UPDATE
**Guys we solved it by using 64bit version of node. That's the issue.
Do NOT use 32bit version.**
Old comment:
Environment:
Angular CLI: 12.0.2 Node: 14.17.0 Package Manager: npm 6.14.13 OS: win32 ia32 Angular: 12.0.2 ... animations, cdk, cli, common, compiler, compiler-cli, core ... forms, localize, material, platform-browser ... platform-browser-dynamic, router, service-worker Package Version --------------------------------------------------------- @angular-devkit/architect 0.1200.2 @angular-devkit/build-angular 12.0.2 @angular-devkit/core 12.0.2 @angular-devkit/schematics 12.0.2 @angular/fire 6.1.5 @schematics/angular 12.0.2 rxjs 6.5.5 typescript 4.2.4
Log:
0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli 'C:\\Program Files (x86)\\nodejs\\node.exe', 1 verbose cli 'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'dev' 1 verbose cli ] 2 info using npm@6.14.13 3 info using node@v14.17.0 4 verbose run-script [ 'predev', 'dev', 'postdev' ] 5 info lifecycle admin@0.1.3~predev: admin@0.1.3 6 info lifecycle admin@0.1.3~dev: admin@0.1.3 7 verbose lifecycle admin@0.1.3~dev: unsafe-perm in lifecycle true 8 verbose lifecycle admin@0.1.3~dev: PATH: C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\prjs\Fabrik\fastorder\admin\node_modules\.bin;C:\Python39\Scripts\;C:\Python39\;C:\Python38\Scripts\;C:\Python38\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Git\cmd;C:\docker;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Yarn\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\GitExtensions\;C:\Program Files (x86)\nodejs\;C:\Users\andre\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Users\andre\AppData\Local\Microsoft\WindowsApps;C:\Users\andre\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\andre\AppData\Local\Yarn\bin;C:\Users\andre\AppData\Local\GitHubDesktop\bin;C:\Users\andre\AppData\Local\Microsoft\WindowsApps;C:\Users\andre\AppData\Roaming\npm;C:\Users\andre\AppData\Roaming\nvm;C:\Program Files\nodejs 9 verbose lifecycle admin@0.1.3~dev: CWD: C:\prjs\Fabrik\fastorder\admin 10 silly lifecycle admin@0.1.3~dev: Args: [ 10 silly lifecycle '/d /s /c', 10 silly lifecycle 'ng serve --host=0.0.0.0 --port=4300 --proxy-config proxy.conf.json --configuration=en --base-href /en --open' 10 silly lifecycle ] 11 silly lifecycle admin@0.1.3~dev: Returned: code: 134 signal: null 12 info lifecycle admin@0.1.3~dev: Failed to exec dev script 13 verbose stack Error: admin@0.1.3 dev: `ng serve --host=0.0.0.0 --port=4300 --proxy-config proxy.conf.json --configuration=en --base-href /en --open` 13 verbose stack Exit status 134 13 verbose stack at EventEmitter.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:376:20) 13 verbose stack at ChildProcess.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:376:20) 13 verbose stack at maybeClose (internal/child_process.js:1055:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) 14 verbose pkgid admin@0.1.3 15 verbose cwd C:\prjs\Fabrik\fastorder\admin 16 verbose Windows_NT 10.0.19042 17 verbose argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev" 18 verbose node v14.17.0 19 verbose npm v6.14.13 20 error code ELIFECYCLE 21 error errno 134 22 error admin@0.1.3 dev: `ng serve --host=0.0.0.0 --port=4300 --proxy-config proxy.conf.json --configuration=en --base-href /en --open` 22 error Exit status 134 23 error Failed at the admin@0.1.3 dev script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 134, true ]
Still crashing with 64bit version of node.
Angular CLI: 12.1.0-next.2 Node: 14.16.0 Package Manager: npm 6.14.13 OS: linux x64
Angular: 12.1.0-next.3 ... compiler-cli, core, language-service
@angular-devkit/architect 0.1201.0-next.2 @angular-devkit/build-angular 12.1.0-next.3 @angular-devkit/build-ng-packagr 0.1002.0 @angular-devkit/core 12.1.0-next.2 @angular-devkit/schematics 12.1.0-next.2 @angular-devkit/schematics-cli 0.1200.0-next.8 @angular/animations 12.1.0-next.2 @angular/cdk 12.0.1 @angular/cli 12.1.0-next.2 @angular/common 12.1.0-next.2 @angular/compiler 12.1.0-next.2 @angular/elements 12.1.0-next.2 @angular/forms 12.1.0-next.2 @angular/material 12.0.1 @angular/platform-browser 12.1.0-next.2 @angular/platform-browser-dynamic 12.1.0-next.2 @angular/router 12.1.0-next.2 @schematics/angular 10.1.0 ng-packagr 12.0.0 rxjs 6.6.6 typescript 4.2.4
@ale-mazz your issue seems unrelated to the one being reported and discussed in this thread.
@qortex, feel free to send me the repro.
@qortex, feel free to send me the repro.
Just sent you an invite, branch is called ng12
. Please let me know where we can chat about it if needed.
@alan-agius4 Pasting here my stacktrace, unfortunately i can't share with you my project cause company's limitations.
β Generating browser application bundles...
<--- Last few GCs --->
[29405:0x5ba1bc0] 460574 ms: Mark-sweep (reduce) 2033.4 (2081.5) -> 2032.3 (2081.3) MB, 3601.4 / 0.1 ms (average mu = 0.088, current mu = 0.043) allocation failure GC in old space requested
[29405:0x5ba1bc0] 463517 ms: Mark-sweep (reduce) 2032.3 (2081.3) -> 2032.3 (2081.0) MB, 2943.3 / 0.1 ms (average mu = 0.048, current mu = 0.000) allocation failure GC in old space requested
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xb14d40 node::Abort() [ng serve app-synergy --port 4200 --open true]
2: 0xa31e30 node::FatalError(char const*, char const*) [ng serve app-synergy --port 4200 --open true]
3: 0xcfb92e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [ng serve app-synergy --port 4200 --open true]
4: 0xcfbca7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [ng serve app-synergy --port 4200 --open true]
5: 0xee5f45 [ng serve app-synergy --port 4200 --open true]
6: 0xee6a8c [ng serve app-synergy --port 4200 --open true]
7: 0xef49c1 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ng serve app-synergy --port 4200 --open true]
8: 0xef7f1c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [ng serve app-synergy --port 4200 --open true]
9: 0xebbdc5 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [ng serve app-synergy --port 4200 --open true]
10: 0xeb6c69 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawArray(int, v8::internal::AllocationType) [ng serve app-synergy --port 4200 --open true]
11: 0xeb6d24 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArrayWithFiller(v8::internal::Handle<v8::internal::Map>, int, v8::internal::Handle<v8::internal::Oddball>, v8::internal::AllocationType) [ng serve app-synergy --port 4200 --open true]
12: 0x103ec4e [ng serve app-synergy --port 4200 --open true]
13: 0x1053db8 [ng serve app-synergy --port 4200 --open true]
14: 0x105409a [ng serve app-synergy --port 4200 --open true]
15: 0x10aee5a v8::internal::JSObject::AddDataElement(v8::internal::Handle<v8::internal::JSObject>, unsigned int, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes) [ng serve app-synergy --port 4200 --open true]
16: 0x10f10f1 v8::internal::Object::AddDataProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::Maybe<v8::internal::ShouldThrow>, v8::internal::StoreOrigin) [ng serve app-synergy --port 4200 --open true]
17: 0x10f52cf v8::internal::Object::SetProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::StoreOrigin, v8::Maybe<v8::internal::ShouldThrow>) [ng serve app-synergy --port 4200 --open true]
18: 0x1247655 v8::internal::Runtime::SetObjectProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::StoreOrigin, v8::Maybe<v8::internal::ShouldThrow>) [ng serve app-synergy --port 4200 --open true]
19: 0x1248777 v8::internal::Runtime_SetKeyedProperty(int, unsigned long*, v8::internal::Isolate*) [ng serve app-synergy --port 4200 --open true]
20: 0x16119d9 [ng serve app-synergy --port 4200 --open true]
Before angular v12 we were able to run it without giving node more than 2gbs of memory, now it crashes even with 6gbs of memory.
@qortex, It appears that for development builds you are using production settings.
This is because a migration was not run during ng-update
because you are using unofficial builders and we cannot know how these builders interact with the builder options and therefore we cannot modify the configuration.
As such it is recommend that such builders provide their own ng-update migration or at least document what needs to change for version 12.
Adding the below to projects.app.architect.build.options
should make things better.
"vendorChunk": true,
"extractLicenses": false,
"buildOptimizer": false,
"sourceMap": true,
"optimization": false,
"namedChunks": true
@ale-mazz, unfortunately, the dump is not helpful. Without at a memory heap and cpu profile we will not be able to get to the bottom of your issue.
@alan-agius4 sent the snapshot via email!
@qortex, It appears that for development builds you are using production settings.
Thanks for looking into it! It did the job indeed.
But now, the prod build goes OOM when run on Heroku :( I think the limit is 2GB. I don't think my project is especially hungry, maybe an artifact of some patterns or practices I have?
I'll open a new issue since it's not about ng serve
.
@alan-agius4 sent the snapshot via email!
Replied back to your email.
Hi all,
Just want to re-cap what is happening in this issue, since there are a lot of comments and important information gets lost.
angular.json
configuration and verify that you are not running
"production" builds during development. (see: https://github.com/angular/angular-cli/issues/20801#issuecomment-850334411)If you are on 12.0.3, and still experiencing OOM during re-builds please report back with with heap snapshots. I'll leave this issue open for a couple of days until people provide confirmation that the issue is no longer preset or/and repros/heap snapshots.
Hi all, yes, I'm still experiencing issues:
I also have it from time to time. Very hard to reproduce though
@alan-agius4 This is the test i did, crashed after 10 minutes of use. On Monday I will send you a snapshot of the memory
https://docs.google.com/document/d/1nzjpJXWU5n7fCV2Yym-yeHZ9VuiykvVqVR8ZL8yLBHk/edit?usp=sharing
great work, @legrottagliegionata
@alan-agius4 I have send the memory 2 snapshots and 2 cpu profile at your e-mail
Hi all, yes, I'm still experiencing issues:
Hey, I'm having the same problem:
<--- Last few GCs --->
[10664:0000021FC8C2FE50] 4891817 ms: Scavenge 2017.3 (2050.6) -> 2012.6 (2052.6) MB, 23.5 / 0.0 ms (average mu = 0.549, current mu = 0.519) allocation failure
[10664:0000021FC8C2FE50] 4893105 ms: Mark-sweep 2038.7 (2072.3) -> 2026.3 (2076.7) MB, 1126.9 / 0.1 ms (average mu = 0.466, current mu = 0.329) allocation fai
lure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
1: 00007FF722F53E0F napi_wrap+108911
2: 00007FF722EF7E16 v8::base::CPU::has_sse+61910
3: 00007FF722EF8D16 node::OnFatalError+294
4: 00007FF7237D0CEE v8::Isolate::ReportExternalAllocationLimitReached+94
5: 00007FF7237B5ACD v8::SharedArrayBuffer::Externalize+781
6: 00007FF72365F95C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1516
7: 00007FF72364A4DB v8::internal::NativeContextInferrer::Infer+59451
8: 00007FF72362F8FF v8::internal::MarkingWorklists::SwitchToContextSlow+56991
9: 00007FF72364358B v8::internal::NativeContextInferrer::Infer+30955
10: 00007FF72363A6AD v8::internal::MarkCompactCollector::EnsureSweepingCompleted+6269
11: 00007FF7236427DE v8::internal::NativeContextInferrer::Infer+27454
12: 00007FF72364679B v8::internal::NativeContextInferrer::Infer+43771
13: 00007FF7236500E2 v8::internal::ItemParallelJob::Task::RunInternal+18
14: 00007FF723650071 v8::internal::ItemParallelJob::Run+641
15: 00007FF723623863 v8::internal::MarkingWorklists::SwitchToContextSlow+7683
16: 00007FF72363AB5C v8::internal::MarkCompactCollector::EnsureSweepingCompleted+7468
17: 00007FF7236393A4 v8::internal::MarkCompactCollector::EnsureSweepingCompleted+1396
18: 00007FF723636F28 v8::internal::MarkingWorklists::SwitchToContextSlow+87240
19: 00007FF723665721 v8::internal::Heap::LeftTrimFixedArray+929
20: 00007FF723667815 v8::internal::Heap::PageFlagsAreConsistent+789
21: 00007FF72365CA71 v8::internal::Heap::CollectGarbage+2033
22: 00007FF72365AC95 v8::internal::Heap::AllocateExternalBackingStore+1349
23: 00007FF723674A05 v8::internal::GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact+1029
24: 00007FF723674E55 v8::internal::Factory::AllocateRaw+37
25: 00007FF7236892FB v8::internal::FactoryBase<v8::internal::Factory>::NewRawOneByteString+75
26: 00007FF72347D15C v8::internal::String::SlowFlatten+396
27: 00007FF72332BF80 unibrow::Utf8::EncodeOneByte+656
28: 00007FF7237DD9DF v8::String::WriteUtf8+175
29: 00007FF722E191F3 v8::internal::HashTable<v8::internal::EphemeronHashTable,v8::internal::EphemeronHashTableShape>::HashTable<v8::internal::EphemeronHashTable
,v8::internal::EphemeronHashTableShape>+37363
30: 00007FF722DC40EC v8_inspector::protocol::Binary::operator=+20092
31: 00007FF722DBCDD4 uv_loop_size+35268
32: 00007FF7237F2F1C v8::internal::SetupIsolateDelegate::SetupHeap+44220
33: 000003EDCA6D4CB0
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! avsi-app@1.0.66 start: `ng serve --open`
npm ERR! Exit status 134
Although it appears minutes/hours (30 minutes/2 hours) after starting angular and developing.
Well I don't have a memory snapshot but I'll be watching to get it next time it happens.
Thanks!
@alan-agius4 I have send the memory 2 snapshots and 2 cpu profile at your e-mail
@legrottagliegionata Alan and myself have looked at those snapshots (huge thanks!!) and I'd like to ask you to apply the following patch to node_modules/@ngtools/webpack/src/ivy/plugin.js
:
diff --git a/plugin.js b/plugin.js
index b36cded..ef4f53a 100644
--- a/plugin.js
+++ b/plugin.js
@@ -396,10 +396,7 @@ class AngularWebpackPlugin {
angularCompiler.incrementalDriver.recordSuccessfulEmit(sourceFile);
});
});
- const analyzingFileEmitter = async (file) => {
- const innerFileEmitter = await pendingAnalysis;
- return innerFileEmitter(file);
- };
+ const analyzingFileEmitter = createAnalyzingFileEmitter(pendingAnalysis);
return {
fileEmitter: analyzingFileEmitter,
builder,
@@ -466,4 +463,10 @@ class AngularWebpackPlugin {
};
}
}
-exports.AngularWebpackPlugin = AngularWebpackPlugin;
\ No newline at end of file
+exports.AngularWebpackPlugin = AngularWebpackPlugin;
+function createAnalyzingFileEmitter(pendingAnalysis) {
+ return async function (file) {
+ const innerFileEmitter = await pendingAnalysis;
+ return innerFileEmitter(file);
+ };
+}
This might help, but I'm not entirely certain at the moment. It would be great if you could give this a go to see if it helps.
We experience the same problems in version 12.0.3. It typically happens when I change the branch (this leads to many changes in different files at the same time) and an incremental build is triggered.
π Bug report
Command (mark with an
x
)Is this a regression?
yes, did not see this issue in Angular 10 or 11
Description
While running
A clear and concise description of the problem... ## π¬ Minimal Reproduction see above ## π₯ Exception or Error ## π Your Environment **Anything else relevant?**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