future.png
珠玑技术随笔
联系/Contact:
future.png

Vue 3 记录错误 Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

2021年08月26日

Hsu

2分钟

背景

正写着项目,突然就挂了,错误信息报这个,内存不够了,电脑内存 16G,一看占用快满了,不知道哪里出问题了,会是 Webpack 的原因吗,还是浏览器或者框架内存泄露了。

接着一试,命令行里 npm、n、ncu 这三个命令一起失效了,node 命令还在。

yarn 还能继续使用。

<--- Last few GCs --->

[4684:0x4dc9a30]  3735158 ms: Mark-sweep 2020.7 (2072.3) -> 2005.9 (2073.1) MB,
910.4 / 0.1 ms  (average mu = 0.225, current mu = 0.163) allocation failure scavenge might not succeed
[4684:0x4dc9a30]  3736396 ms: Mark-sweep 2022.4 (2073.5) -> 2008.4 (2075.3) MB,
1125.7 / 0.1 ms  (average mu = 0.155, current mu = 0.091) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

 1: 0xa03530 node::Abort() [/usr/local/bin/node]
 2: 0x94e471 node::FatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0xb7773e v8::Utils::ReportOOMFailure(v8::internal::Isolate*,
  char const*,
 bool) [/usr/local/bin/node]
 4: 0xb77ab7 v8::internal::V8::FatalProcessOutOfMemory(
  v8::internal::Isolate*,
  char const*, bool) [/usr/local/bin/node]
 5: 0xd32345  [/usr/local/bin/node]
 6: 0xd32ecf  [/usr/local/bin/node]
 7: 0xd40f5b v8::internal::Heap::CollectGarbage(
  v8::internal::AllocationSpace,
  v8::internal::GarbageCollectionReason,
  v8::GCCallbackFlags) [/usr/local/bin/node]
 8: 0xd44b1c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(
  int,
  v8::internal::AllocationType,
  v8::internal::AllocationOrigin,
  v8::internal::AllocationAlignment
  ) [/usr/local/bin/node]
 9: 0xd131fb v8::internal::Factory::NewFillerObject(
  int,
  bool,
  v8::internal::AllocationType,
  v8::internal::AllocationOrigin
  ) [/usr/local/bin/node]
10: 0x105919f v8::internal::Runtime_AllocateInYoungGeneration(
  int,
  unsigned long*,
  v8::internal::Isolate*) [/usr/local/bin/node]
11: 0x13ff179  [/usr/local/bin/node]
Aborted (core dumped)
error Command failed with exit code 134.

解决

目前除了重装,找不到别的办法。

n https://github.com/tj/n
ncu https://github.com/raineorshine/npm-check-updates