[Fixed] AWS code Pipeline error FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed – JavaScript heap out of memory


i have angular application running on aws code pipeline and suddenly it start throwing this error. i did lot of this including "node –max-old-space-size=8192" etc ..! but nothing resolve this error. can someone please help me to resolve this.

   To disable this warning use "ng config -g cli.warnings.versionMismatch false".

<--- Last few GCs --->

[181:0x4ab9280]    99247 ms: Mark-sweep 2028.9 (2081.8) -> 2018.6 (2087.2) MB, 1481.7 / 0.0 ms  (average mu = 0.125, current mu = 0.028) allocation failure scavenge might not succeed
[181:0x4ab9280]   100721 ms: Mark-sweep 2021.2 (2087.2) -> 2018.5 (2087.0) MB, 1464.8 / 0.0 ms  (average mu = 0.069, current mu = 0.006) allocation failure GC in old space requested

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x13cb519]
Security context: 0x1308cef008d1 <JSObject>
    1: add [0x1308cef0b101](this=0x09332a9b8e61 <Set map = 0x33764a780a29>,0x22118ef17ee9 <Scope map = 0x12cadd78a529>)
    2: addScopeSymbols1(aka addScopeSymbols1) [0x27c6ba252f61] [/codebuild/output/src879897097/src/node_modules/webpack/lib/optimize/ConcatenatedModule.js:~207] [pc=0x36ab68da2da6](this=0x09e7d26004b1 <undefined>,0x22118ef17ee9 <Scope map = 0x12...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xa07f90 node::Abort() [ng build --configuration DEV]
 2: 0xa0839c node::OnFatalError(char const*, char const*) [ng build --configuration DEV]
 3: 0xb80d9e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [ng build --configuration DEV]
 4: 0xb81119 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [ng build --configuration DEV]
 5: 0xd2d875  [ng build --configuration DEV]
 6: 0xd2df06 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [ng build --configuration DEV]
 7: 0xd3a785 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [ng build --configuration DEV]
 8: 0xd3b635 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ng build --configuration DEV]
 9: 0xd3e0ec v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [ng build --configuration DEV]
10: 0xd0502d v8::internal::Factory::NewFixedArrayWithFiller(v8::internal::RootIndex, int, v8::internal::Object, v8::internal::AllocationType) [ng build --configuration DEV]
11: 0xd05120 v8::internal::Handle<v8::internal::FixedArray> v8::internal::Factory::NewFixedArrayWithMap<v8::internal::FixedArray>(v8::internal::RootIndex, int, v8::internal::AllocationType) [ng build --configuration DEV]
12: 0xf325bd v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::Allocate(v8::internal::Isolate*, int, v8::internal::AllocationType) [ng build --configuration DEV]
13: 0xf3266f v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::Rehash(v8::internal::Isolate*, v8::internal::Handle<v8::internal::OrderedHashSet>, int) [ng build --configuration DEV]
14: 0xf32c4b v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::EnsureGrowable(v8::internal::Isolate*, v8::internal::Handle<v8::internal::OrderedHashSet>) [ng build --configuration DEV]
15: 0x1029ac8 v8::internal::Runtime_SetGrow(int, unsigned long*, v8::internal::Isolate*) [ng build --configuration DEV]
16: 0x13cb519  [ng build --configuration DEV]

[Container] 2020/12/13 15:41:31 Command did not exit successfully ng build --configuration $ENV exit status 134
[Container] 2020/12/13 15:41:31 Phase complete: BUILD State: FAILED
[Container] 2020/12/13 15:41:31 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: ng build --configuration $ENV. Reason: exit status 134


i fixed this using multiple options

  1. use node –max-old-space-size=4096
  2. remove lots of lots of duplicate css
  3. remove some of the duplicate js

Leave a Reply

(*) Required, Your email will not be published