提问者:小点点

TypeScript Server问题致命错误:堆限制附近的无效标记压缩分配失败-JavaScript堆内存溢出


在我的CRA项目中,每次我运行它时,我都会在我的控制台中遇到这个错误。我认为这是由于打字稿服务器。有办法解决它吗?

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% 

共3个答案

匿名用户

这可能是由于内存泄漏。只是增加分配给Node. js的内存可能会解决错误。

在您的终端中键入以下内容:

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

如果您使用的是Windows运行:

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

注意:size=2048是您将在(MB)中分配给node. js的内存,默认为512MB

匿名用户

我今天遇到了同样的问题,以下是我如何解决的:

  1. 将这些行添加到您的jest. config.js
coverageProvider: 'v8'
"jest -w 1"

如果不工作,请考虑升级您的节点版本,至少到16.10

匿名用户

它适用于我,在Ubuntu上,但值必须是5096(否则失败)。