gpt4 book ai didi

node.js - nodejs fatal error : CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

转载 作者:太空宇宙 更新时间:2023-11-03 22:08:19 25 4
gpt4 key购买 nike

有时会出现此错误。

<--- Last few GCs --->                                                                                                                                                                                                          
[2856:00000253F09D3B90] 11688472 ms: Mark-sweep 1529.8 (1619.4) -> 1529.7 (1583.4) MB, 1835.6 / 0.0 ms last resort GC in old space requested

[2856:00000253F09D3B90] 11690272 ms: Mark-sweep 1529.7 (1583.4) -> 1529.7 (1579.4) MB, 1799.7 / 0.0 ms last resort GC in old space requested

<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000001F6C9E25739 <JSObject>
1: completeMany [C:\Users\mobasher.fasihy\Documents\GitHub\jobsaf-server\node_modules\mongoose\lib\query.js:~1459] [pc=0000006F3C3482B8](this=0000029E4B604F01 <JSGlobal Object>,model=00000090CCBE6729 <JSFunction model (sfi = 000001A244DDB931)>,docs=0000025B74FA8591
<JSArray[53714]>,fields=0000025B74FA8FF1 <Object map = 00000207F58823B9>,userProvidedFields=0000025B74FA9029 <Object map = 000...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::DecodeWrite
2: node_module_register
3: v8::internal::FatalProcessOutOfMemory
4: v8::internal::FatalProcessOutOfMemory
5: v8::internal::Factory::NewUninitializedFixedArray
6: v8::internal::WasmDebugInfo::SetupForTesting
7: v8::internal::interpreter::BytecodeArrayRandomIterator::UpdateOffsetFromIndex
8: 0000006F3C2043C1
[nodemon] app crashed - waiting for file changes before starting...

服务器上随机出现上述错误,并且应用程序崩溃。

最佳答案

虽然您可以使用 David 的解决方法,但我建议您寻找根本原因。

内存不足错误的可能原因并不多:

  • 递归调用时间太长,以至于破坏了堆栈跟踪
  • 您创建了一个非常重的物体
  • 您一次获得了大量数据

如果根本原因是递归调用(当 Node.js 充满回调时,这是一个常见错误),则有一行将控制权交还给事件循环,以便它可以自行清除(process.nextTick 或类似的东西)

对于另外两个原因,这两个原因现在是最有可能的罪魁祸首,特别是在使用数据库时,您将需要使用流,这样您就永远不会在内存中立即获取完整的数据,或者找到另一种方法来划分工作。

关于node.js - nodejs fatal error : CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49852658/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com