angularheap-memory

Reached heap limit Allocation failed - Javascript heap out of memory, even though my laptop has 32GB RAM


I just bought a new device for better work performance, and tried to run my project on it. It is an angular project that uses angular 11, and in my old laptop normally I have to set max old space size to 8GB from 4GB so it can run. I tried it on my new laptop, but received the same message. I tried to set the max size to 16GB, same thing.

Generating browser application bundles (phase: building)...
<--- Last few GCs --->

[14740:000001E98859B110]   125607 ms: Mark-sweep 3975.7 (4135.4) -> 3963.7 (4139.1) MB, 1093.7 / 0.1 ms  (average mu = 0.491, current mu = 0.203) allocation failure scavenge might not succeed
[14740:000001E98859B110]   127648 ms: Mark-sweep 3980.6 (4139.4) -> 3969.4 (4144.1) MB, 1976.7 / 0.0 ms  (average mu = 0.267, current mu = 0.032) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF69A2F7B7F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114079
 2: 00007FF69A284546 DSA_meth_get_flags+65542
 3: 00007FF69A2853FD node::OnFatalError+301
 4: 00007FF69ABBB29E v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF69ABA587D v8::SharedArrayBuffer::Externalize+781
 6: 00007FF69AA48C4C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468
 7: 00007FF69AA45D64 v8::internal::Heap::CollectGarbage+4244
 8: 00007FF69AA436E0 v8::internal::Heap::AllocateExternalBackingStore+2000
 9: 00007FF69AA68266 v8::internal::Factory::NewFillerObject+214
10: 00007FF69A79A735 v8::internal::DateCache::Weekday+1797
11: 00007FF69AC48F91 v8::internal::SetupIsolateDelegate::SetupHeap+494417
12: 000001E98AC24E95

I think it supposed to run smoothly due to the specs of the device, and tried searching for solutions but can't find anything.


Solution

  • Solved.

    I have to settle with using

    node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve

    directly on command line. For now this will have to do. Thanks to all who chimed in for solutions