javascripttypescriptv8typescript-compiler-api

FATAL ERROR: Ineffective mark-compacts near heap limit


I am getting this error. Could somebody provide me with a small explanation? I don't even know what I need to fix.

I am getting this error during typescript compilation.



<--- Last few GCs --->

[1791:0x5533880]    72626 ms: Scavenge (reduce) 2042.8 (2082.2) -> 2042.1 (2082.5) MB, 10.0 / 0.0 ms  (average mu = 0.287, current mu = 0.243) allocation failure 
[1791:0x5533880]    74247 ms: Mark-sweep (reduce) 2043.0 (2082.5) -> 2037.5 (2082.5) MB, 1617.4 / 0.0 ms  (average mu = 0.225, current mu = 0.159) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb09c10 node::Abort() [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 2: 0xa1c193 node::FatalError(char const*, char const*) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 3: 0xcf8dbe v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 4: 0xcf9137 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 5: 0xeb09d5  [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 6: 0xeb14b6  [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 7: 0xebf9de  [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 8: 0xec0420 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 9: 0xec339e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
10: 0xe848da v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
11: 0x11fd626 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
12: 0x15f2099  [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]

Node.js : 16.15.0 TypeScript : 4.2.4


Solution

  • Your memory consumption is at ~2GB, and the garbage collector is unable to free up any, despite trying very hard. Some allocation request needs more memory than is left available, so a crash is the only option to deal with that.

    Solution 1: use less memory. The details depend on your application:

    Solution 2: allow Node to use more memory by using --max-old-space-size=3000 (or some other value greater than the current/default limit; the value is in megabytes).