[FIXED] FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed – JavaScript heap out of memory

Issue

Whenever I build using ng build I get the following error. The project I’m working on is an angular 12 with primeface template.

I’ve tried the following which did not work

set NODE_OPTIONS=--max-old-space-size=8192
<--- Last few GCs --->

[20368:00000209E3C2B160]    34896 ms: Mark-sweep (reduce) 4092.5 (4101.4) -> 4092.1 (4106.9) MB, 3198.8 / 0.0 ms  (+ 0.1 ms in 291 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 3322 ms) (average mu = 0.254, current mu [20368:00000209E3C2B160]    40386 ms: Mark-sweep (reduce) 4093.1 (4104.9) -> 4092.7 (4105.2) MB, 5489.4 / 0.1 ms  (average mu = 0.102, current mu = 0.000) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
 1: 00007FF7AF4F428F napi_wrap+133311
 2: 00007FF7AF48DE66 SSL_get_quiet_shutdown+63062
 3: 00007FF7AF48ECFD node::OnFatalError+301
 4: 00007FF7AFD71B2E v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF7AFD5691D v8::SharedArrayBuffer::Externalize+781
 6: 00007FF7AFC0012C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1516
 7: 00007FF7AFBEABAB v8::internal::NativeContextInferrer::Infer+59739
 8: 00007FF7AFBCFE7F v8::internal::MarkingWorklists::SwitchToContextSlow+56975
 9: 00007FF7AFBE3B6B v8::internal::NativeContextInferrer::Infer+31003
10: 00007FF7AFBDAC4D v8::internal::MarkCompactCollector::EnsureSweepingCompleted+6285
11: 00007FF7AFBE2DBE v8::internal::NativeContextInferrer::Infer+27502
12: 00007FF7AFBE6E0B v8::internal::NativeContextInferrer::Infer+43963
13: 00007FF7AFBF0802 v8::internal::ItemParallelJob::Task::RunInternal+18
14: 00007FF7AFBF0791 v8::internal::ItemParallelJob::Run+641
15: 00007FF7AFBC3DF3 v8::internal::MarkingWorklists::SwitchToContextSlow+7683
16: 00007FF7AFBDB0FC v8::internal::MarkCompactCollector::EnsureSweepingCompleted+7484
17: 00007FF7AFBD9934 v8::internal::MarkCompactCollector::EnsureSweepingCompleted+1396
18: 00007FF7AFBD74A8 v8::internal::MarkingWorklists::SwitchToContextSlow+87224
19: 00007FF7AFC05F11 v8::internal::Heap::LeftTrimFixedArray+929
20: 00007FF7AFC08005 v8::internal::Heap::PageFlagsAreConsistent+789
21: 00007FF7AFBFD221 v8::internal::Heap::CollectGarbage+2049
22: 00007FF7AFBFB425 v8::internal::Heap::AllocateExternalBackingStore+1349
23: 00007FF7AFC1B89B v8::internal::Factory::NewFillerObject+203
24: 00007FF7AF94A0E1 v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+1409
25: 00007FF7AFDFCF5D v8::internal::SetupIsolateDelegate::SetupHeap+474253
26: 00000048464760F0

Solution

So I knew it was a syntax error because I didn’t install any packages or make any changes to the project.

It turns out I found a code example.

<div class="p-field" *ngIf="column.fieldType =='date'">
    <label [for]="column.field">{{column.header}}</label>
    <p-calendar [id]="column.field" 
    [(ngModel)]="selectedItem[column.field] | date:'dd/MM/yyyy hh:mm a'"
    [showIcon]="true" [required]="column.required" [name]="column.field">
</p-calendar>
</div>

If I remove the following from within ngModel, the code compiles.

 | date:'dd/MM/yyyy hh:mm a'

Answered By – Magood

Answer Checked By – Senaida (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published