NodeJS 打字脚本服务器问题致命错误:无效的标记压缩接近堆限制分配失败- JavaScript堆内存不足

thtygnil  于 2023-02-12  发布在  Node.js
关注(0)|答案(2)|浏览(222)

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

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%
kyks70gy

kyks70gy1#

这可能是由于内存泄漏造成的。只需增加分配给Node.js的内存即可解决该错误。
在终端中键入以下内容:

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

如果你正在使用windows运行:

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

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

o4tp2gmn

o4tp2gmn2#

我今天遇到了同样的问题,下面是我如何解决它:
1.将这些行添加到jest.config.js

coverageProvider: 'v8'

1.添加到您的jest测试覆盖率命令

"jest -w 1"

如果不起作用,请考虑将节点版本升级到至少16.10

相关问题