Typescript Server Issue FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Asked Answered
O

4

10

in my CRA project each single time I ran it I faced this error in my console. I think it is due to typescript server. Is there a way to solve it ?

99% done plugins webpack-hot-middlewarewebpack built preview 7c330f0bfd3e44c3a97b in 6446ms
Issues checking in progress...

<--- Last few GCs --->

[15997:0x7fccd3700000]   618460 ms: Mark-sweep (reduce) 2043.8 (2082.1) -> 2042.4 (2082.1) MB, 3304.1 / 0.0 ms  (average mu = 0.202, current mu = 0.179) allocation failure scavenge might not succeed
[15997:0x7fccd3700000]   622127 ms: Mark-sweep (reduce) 2043.5 (2082.1) -> 2042.4 (2081.8) MB, 3661.0 / 0.0 ms  (average mu = 0.106, current mu = 0.002) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10e141815 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x10ce40aa9 node::Abort() [/usr/local/bin/node]
 3: 0x10ce40c1f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x10cfc1877 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x10cfc1813 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 6: 0x10d162c65 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 7: 0x10d166cad v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 8: 0x10d16358d v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0x10d160aad v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
10: 0x10d16dde0 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x10d16de61 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
12: 0x10d13afb7 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
13: 0x10d4f089e v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
14: 0x10d89a2b9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
15: 0x10d82a983 Builtins_FastNewClosure [/usr/local/bin/node]
16: 0x119cedeb8 
RpcIpcMessagePortClosedError: Process 15997 exited [SIGABRT].
Issues checking service aborted - probably out of memory. Check the `memoryLimit` option in the ForkTsCheckerWebpackPlugin configuration.
If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript or EsLint.
RpcIpcMessagePortClosedError: Process 15997 exited [SIGABRT].
Issues checking service aborted - probably out of memory. Check the `memoryLimit` option in the ForkTsCheckerWebpackPlugin configuration.
If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript or EsLint.
webpack building...
99% 
Otiose answered 28/6, 2022 at 10:42 Comment(2)
what node.js version are you using ?Cheung
@Cheung is use thev16.13.1Otiose
C
9

This might be due to a leak of memory . just increasing the memory allocated to Node.js may solve the error .

In your terminal type this:

export NODE_OPTIONS="--max-old-space-size=2048"

if you are using windows run :

export NODE_OPTIONS="--max-old-space-size=2048"

Note : size=2048 is the memory you will allocate in (MB) to node.js the default is 512 MB

Cheung answered 28/6, 2022 at 11:4 Comment(3)
I still have the same issueOtiose
It works for me, on Mac, but with 5096 instead of 2048 (otherwise it fails).Flagellate
I was trying to upgrade to use TS compilerOptions:target:ES2023 and tried even up to 8000 but it still ran out... then reverting to ES2021 seems to use less memory.Floe
M
1

Update: if you get this issue while running unit tests with Jest, this could solve it.

I ran into the same issue today, here is how I solved it:

  1. Add these line to your jest.config.js
coverageProvider: 'v8'
  1. Add to your jest test coverage command
"jest -w 1"

If it is not working, consider upgrading your node version, to at least 16.10

Misogynist answered 9/2, 2023 at 21:57 Comment(1)
What does Jest have to do with this error?Calla
U
0

It works for me, on Ubuntu, but the value must be 5096 (otherwise it fails).

Underprop answered 23/3, 2023 at 3:39 Comment(0)
B
0

I don't know if it's too late for the answer, but the issue is the available memory. If trying to dockerize the application, make sure that you set sufficient memory allocation in Docker desktop. Go to:

Settings -> Resources -> Increase Swap and Memory limits

For me 4 GB memory limit and 2GB swap size solved the issue.

Byler answered 10/7 at 9:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.