我如何找出导致 JavaScript 堆内存不足的代码
How do I find out what code is causing JavaScript heap out of memory
我正在尝试 运行 yarn start
但得到这个:
Starting the development server...
ts-loader: Using typescript@3.9.10 and C:\DevTools\git\mymoto\tsconfig.json
<--- Last few GCs --->
[9076:000001F4910F0DA0] 120343 ms: Mark-sweep (reduce) 2045.0 (2051.8) -> 2044.3 (2053.0) MB, 1410.7 / 0.0 ms (average mu = 0.123, current mu = 0.011) allocation failure scavenge might not succeed
[9076:000001F4910F0DA0] 122662 ms: Mark-sweep (reduce) 2045.4 (2052.0) -> 2044.6 (2053.0) MB, 2288.3 / 0.0 ms (average mu = 0.057, current mu = 0.013) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF79BA7021F napi_wrap+109311
2: 00007FF79BA15286 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfElementsOffset+33302
3: 00007FF79BA16056 node::OnFatalError+294
4: 00007FF79C2E054E v8::Isolate::ReportExternalAllocationLimitReached+94
5: 00007FF79C2C53CD v8::SharedArrayBuffer::Externalize+781
6: 00007FF79C16F85C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1516
7: 00007FF79C17AB9A v8::internal::Heap::ProtectUnprotectedMemoryChunks+1258
8: 00007FF79C177D49 v8::internal::Heap::PageFlagsAreConsistent+2457
9: 00007FF79C16C971 v8::internal::Heap::CollectGarbage+2033
10: 00007FF79C16AB75 v8::internal::Heap::AllocateExternalBackingStore+1317
11: 00007FF79C18AF67 v8::internal::Factory::NewFillerObject+183
12: 00007FF79BEBAFF1 v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+1409
13: 00007FF79C368EFD v8::internal::SetupIsolateDelegate::SetupHeap+463949
14: 000001177FAE26D4
我在这里看到了一些问题,它们似乎都暗示了与 node --max_old_space_size=8048
类似的内容。在大多数情况下,问题突出显示了导致此问题的代码。我不知道这是什么。我如何找出导致问题的原因?我想首先看看那里是否有任何问题,而不是盲目尝试。
项目文件夹中有我的 node_modules
文件夹的副本会不会以任何方式导致此问题?
不久前遇到过这个问题。这对我有帮助
node --max-old-space-size=8048
您尝试过使用 NVM 吗?降级 Node/Typescript 版本可以帮助您。顺便说一句,我使用了 Node v14.15.5。
我有我的 node_modules
文件夹和一个 node_modules_backup
。当我删除 node_modules_backup
时,问题就解决了。
我正在尝试 运行 yarn start
但得到这个:
Starting the development server...
ts-loader: Using typescript@3.9.10 and C:\DevTools\git\mymoto\tsconfig.json
<--- Last few GCs --->
[9076:000001F4910F0DA0] 120343 ms: Mark-sweep (reduce) 2045.0 (2051.8) -> 2044.3 (2053.0) MB, 1410.7 / 0.0 ms (average mu = 0.123, current mu = 0.011) allocation failure scavenge might not succeed [9076:000001F4910F0DA0] 122662 ms: Mark-sweep (reduce) 2045.4 (2052.0) -> 2044.6 (2053.0) MB, 2288.3 / 0.0 ms (average mu = 0.057, current mu = 0.013) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF79BA7021F napi_wrap+109311 2: 00007FF79BA15286 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfElementsOffset+33302 3: 00007FF79BA16056 node::OnFatalError+294 4: 00007FF79C2E054E v8::Isolate::ReportExternalAllocationLimitReached+94 5: 00007FF79C2C53CD v8::SharedArrayBuffer::Externalize+781 6: 00007FF79C16F85C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1516 7: 00007FF79C17AB9A v8::internal::Heap::ProtectUnprotectedMemoryChunks+1258 8: 00007FF79C177D49 v8::internal::Heap::PageFlagsAreConsistent+2457 9: 00007FF79C16C971 v8::internal::Heap::CollectGarbage+2033 10: 00007FF79C16AB75 v8::internal::Heap::AllocateExternalBackingStore+1317 11: 00007FF79C18AF67 v8::internal::Factory::NewFillerObject+183 12: 00007FF79BEBAFF1 v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+1409 13: 00007FF79C368EFD v8::internal::SetupIsolateDelegate::SetupHeap+463949 14: 000001177FAE26D4
我在这里看到了一些问题,它们似乎都暗示了与 node --max_old_space_size=8048
类似的内容。在大多数情况下,问题突出显示了导致此问题的代码。我不知道这是什么。我如何找出导致问题的原因?我想首先看看那里是否有任何问题,而不是盲目尝试。
项目文件夹中有我的 node_modules
文件夹的副本会不会以任何方式导致此问题?
不久前遇到过这个问题。这对我有帮助
node --max-old-space-size=8048
您尝试过使用 NVM 吗?降级 Node/Typescript 版本可以帮助您。顺便说一句,我使用了 Node v14.15.5。
我有我的 node_modules
文件夹和一个 node_modules_backup
。当我删除 node_modules_backup
时,问题就解决了。