gpt4 book ai didi

node.js - Node --max_old_space_size 不工作

转载 作者:搜寻专家 更新时间:2023-10-31 23:32:24 26 4
gpt4 key购买 nike

Node 版本:6.9.x

我的应用程序出现了 FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 错误。

所以我尝试使用 max_old_space_size 标志更改内存分配

在执行我的 server.js 时,我给出了 --max_old_space_size=4096 参数。

但是,它一直崩溃并出现与以前相同的错误。另外,我注意到崩溃时抛出的错误中的数字。看起来它仍然是 1.4 GB 的默认分配。

这是我的错误信息:

<--- Last few GCs --->

84567 ms: Mark-sweep 1375.1 (1401.9) -> 1374.7 (1402.9) MB, 88.7 / 0.4 ms (+ 0.8 ms in 3 steps since start of marking, biggest step 0.5 ms) [allocation failure] [GC in old space requested].
84648 ms: Mark-sweep 1374.7 (1402.9) -> 1374.7 (1402.9) MB, 81.3 / 0.0 ms [allocation failure] [GC in old space requested].
84734 ms: Mark-sweep 1374.7 (1402.9) -> 1374.3 (1401.9) MB, 86.0 / 0.0 ms [last resort gc].
84825 ms: Mark-sweep 1374.3 (1401.9) -> 1374.0 (1400.9) MB, 90.9 / 0.0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x1bf641bcfb39 <JS Object>
1: slowToString [buffer.js:460] [pc=0x2f7049a5d3d5] (this=0x93e46a2d6b1 <an Uint8Array with map 0x13be78e068d9>,encoding=0x1bf641bdd309 <String[4]: utf8>,start=53,end=3522765)
2: toString [buffer.js:~488] [pc=0x2f70499b77a6] (this=0x93e46a2d6b1 <an Uint8Array with map 0x13be78e068d9>)
3: arguments adaptor frame: 3->0
4: deserialize [/opt/myServer/node_modu...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [node]
2: 0x10d2fbc [node]
3: v8::Utils::ReportApiFailure(char const*, char const*) [node]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
5: v8::internal::Factory::NewRawOneByteString(int, v8::internal::PretenureFlag) [node]
6: v8::internal::Factory::NewStringFromOneByte(v8::internal::Vector<unsigned char const>, v8::internal::PretenureFlag) [node]
7: v8::internal::Factory::NewStringFromUtf8(v8::internal::Vector<char const>, v8::internal::PretenureFlag) [node]
8: v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int) [node]
9: node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding) [node]
10: node::Buffer::Utf8Slice(v8::FunctionCallbackInfo<v8::Value> const&) [node]
11: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
12: 0x9da914 [node]
13: 0x9daffe [node]
14: 0x2f7047a092a7
Aborted (core dumped)

在“最近几次 GC”部分,提到的内存大小始终在 1404 MB 左右。我做错了什么?

系统是不是不能再给它分配内存了?

最佳答案

确保将选项放在脚本的文件名之前:

  • 正确:node --max-old-space-size=10000 index.js
  • 不正确:node index.js --max-old-space-size=10000

这个让我有一段时间了。

关于node.js - Node --max_old_space_size 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43585185/

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