Skip to content

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory #22020

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

Closed
14 tasks
AlKoch opened this issue Oct 26, 2021 · 3 comments
Closed
14 tasks

Comments

@AlKoch
Copy link

AlKoch commented Oct 26, 2021

🐞 Bug report

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

Is this a regression?

No - this just started happening without any (immediately prior) updates/upgrades

Description

I am using VS Code (with the Nrwl nx extension) to build the Angular app. My initial "serve" works but once I make a change and the project is rebuilt I have started crashing with the error stack shown later. I have to exit VS Code, restart VS Code and then I can get (exactly) one serve before the problem happens again.

I have read issue #13734 and have added a Windows (System) Environment variable of NODE_OPTIONS set to --max-old-space-size=8096. (I had previously been running successfully with the Node default). I have also tried modifying the scripts to do the same as seen below.

I have seen suggestions that this error could be caused by a Garbage Collection failure but since this is happening in the build ("serve") I have no way to implemement the suggested steps to "force a call to the GC".

🔬 Minimal Reproduction

VS Code 1.61.2
node 14.18.1
"@angular/compiler-cli": "^12.2.4",
"@nrwl/angular": "^12.8.0",
"@nrwl/cli": "12.8.0",
package.json:
"scripts": {
"ng": "node --max_old_space_size=8192 ./node_modules/.bin/ng",
"start": "node --max_old_space_size=8192 nx serve",
"build": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build",
"build-prod": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod",
"test": "nx test",
"postinstall": "ngcc --properties es2015 browser module main"
},

npx nx serve my-app --poll=2000 --progress

🔥 Exception or Error


Compiled successfully.
Generating browser application bundles (phase: sealing)...
<--- Last few GCs --->

[2460:00000103CF2FF160]  3313350 ms: Mark-sweep (reduce) 1970.1 (2005.5) -> 1969.3 (2005.8) MB, 643.9 / 0.1 ms  (average mu = 0.831, current mu = 0.000) last resort GC in old space requested
[2460:00000103CF2FF160]  3314028 ms: Mark-sweep (reduce) 1969.3 (2004.8) -> 1968.2 (2005.5) MB, 677.9 / 0.1 ms  (average mu = 0.690, current mu = 0.000) last resort GC in old space requested


<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 00007FF6F3B6412F napi_wrap+133311
 2: 00007FF6F3AFDD06 SSL_get_quiet_shutdown+63062
 3: 00007FF6F3AFEB9D node::OnFatalError+301
 4: 00007FF6F43E19CE v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF6F43C67BD v8::SharedArrayBuffer::Externalize+781
 6: 00007FF6F426FFCC v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1516
 7: 00007FF6F426B3C1 v8::internal::Heap::AllocateExternalBackingStore+1601
 8: 00007FF6F4285155 v8::internal::GCIdleTimeHandler::ShouldDoContextDisposalMarkCompact+1029
 9: 00007FF6F42855A5 v8::internal::Factory::AllocateRaw+37
10: 00007FF6F4299C1F v8::internal::FactoryBase::NewRawTwoByteString+79
11: 00007FF6F408D2B9 v8::internal::String::SlowFlatten+441
12: 00007FF6F3F3BE20 unibrow::Utf8::EncodeOneByte+656
13: 00007FF6F43ED456 v8::String::Utf8Length+22
14: 00007FF6F3B1DA67 v8::internal::Malloced::operator delete+21831
15: 00007FF6F438E9CF v8::internal::Builtins::builtin_handle+322591
16: 00007FF6F438DF64 v8::internal::Builtins::builtin_handle+319924
17: 00007FF6F438E258 v8::internal::Builtins::builtin_handle+320680
18: 00007FF6F438E0A3 v8::internal::Builtins::builtin_handle+320243
19: 00007FF6F446CEDD v8::internal::SetupIsolateDelegate::SetupHeap+474477
20: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
21: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
22: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
23: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
24: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
25: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
26: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
27: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
28: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
29: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
30: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
31: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
32: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
33: 00007FF6F43FCBF9 v8::internal::SetupIsolateDelegate::SetupHeap+14985
34: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
35: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
36: 00007FF6F4402FC2 v8::internal::SetupIsolateDelegate::SetupHeap+40530
37: 00007FF6F4400C7E v8::internal::SetupIsolateDelegate::SetupHeap+31502
38: 00007FF6F440086C v8::internal::SetupIsolateDelegate::SetupHeap+30460
39: 00007FF6F42D09D2 v8::internal::Execution::CallWasm+1650
40: 00007FF6F42D023F v8::internal::Execution::Call+191
41: 00007FF6F43BBB97 v8::Function::Call+615
42: 00007FF6F3B90D1B node::CallbackScope::~CallbackScope+1723
43: 00007FF6F3B91181 node::MakeCallback+209
44: 00007FF6F3B51900 napi_wrap+57488
45: 00007FF6F3BB6328 uv_check_init+120
46: 00007FF6F3BC0F18 uv_run+664
47: 00007FF6F3AB8A45 v8::internal::AsmJsScanner::GetIdentifierString+51749
48: 00007FF6F3B31227 node::Start+311
49: 00007FF6F398685C RC4_options+339804
50: 00007FF6F49414F8 v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+14424
51: 00007FFAB4FB7034 BaseThreadInitThunk+20
52: 00007FFAB5D62651 RtlUserThreadStart+33

🌍 Your Environment

Windows 10

@alan-agius4
Copy link
Collaborator

Hi @AlKoch,

The error message highlights (1969.3 (2004.8) -> 1968.2 (2005.5) MB) that default Node.Js memory limit is still effective.

That said, this is a duplicate of #20801. I suggest you provide memory heap snapshots or share a reproduction even privately.

@EDGESoftware
Copy link

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

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

No branches or pull requests

3 participants