NodeJS-如何增加内存堆大小?

时间:2019-11-15 00:01:22

标签: node.js

我想增加内存堆的大小,但是每次尝试这样做都会失败。我试图安装软件包npm i increase-memory-limit,但它没有任何作用。我在安装后确实运行了命令increase-memory-limit,但是仍然遇到与以前相同的崩溃。

当前,如果有帮助,我正在Windows 10的PyCharm IDE中编写我的NodeJS代码。

编辑:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 00007FF686C0094F napi_wrap+124431
 2: 00007FF686BA2696 v8::base::CPU::has_sse+34502
 3: 00007FF686BA3356 v8::base::CPU::has_sse+37766
 4: 00007FF6873A6F4E v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF68738EF91 v8::SharedArrayBuffer::Externalize+833
 6: 00007FF68725C85C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436
 7: 00007FF687258890 v8::internal::Heap::AddRetainedMap+2608
 8: 00007FF68727289E v8::internal::Factory::AllocateRawFixedArray+94
 9: 00007FF687279C34 v8::internal::Factory::NewFixedArrayWithFiller+52
10: 00007FF687279BF1 v8::internal::Factory::NewFixedArray+65
11: 00007FF68714A98F v8::internal::FeedbackNexus::ic_state+56767
12: 00007FF68715C6C5 v8::Message::GetIsolate+14101
13: 00007FF687168600 v8::Message::GetIsolate+63056
14: 00007FF68714438C v8::internal::FeedbackNexus::ic_state+30652
15: 00007FF68700E8AA v8::internal::OrderedHashMap::ValueAt+62122
16: 00007FF6877D2C6D v8::internal::SetupIsolateDelegate::SetupHeap+567949
17: 000002A6CAD8B865 

1 个答案:

答案 0 :(得分:0)

启动节点服务器时,请检查正在运行的脚本 应该是node index.js之类的。

在运行节点时不确定它在PyCharm中的状态 但是可以帮助您的是选项--max-old-space-size

所以,我建议尝试使用类似的命令

node --max-old-space-size=8192 index.js