我得到这个错误:
FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory
字符串
但我使用的是--max-old-space-size=12288
,内存为16 GB
使用process.memoryUsage()
,我可以看到堆只有~1GB;此外,错误总是发生在同一行代码上,即types.js:~94
,这是我正在使用的库的一部分。
这让我觉得在某个地方有一个bug,也许在我传递给函数的参数中,但我不知道如何发现它。
我应该找什么?
完整的错误是:
<--- Last few GCs --->
[28425:0x2739620] 406975 ms: Scavenge 3689.5 (3833.4) -> 3673.7 (3833.9) MB, 4.2 / 0.0 ms (average mu = 0.991, current mu = 0.990) allocation failure
[28425:0x2739620] 407874 ms: Scavenge 3728.8 (3873.4) -> 3713.1 (3873.9) MB, 4.5 / 0.0 ms (average mu = 0.991, current mu = 0.990) allocation failure
[28425:0x2739620] 408785 ms: Scavenge 3768.1 (3913.4) -> 3752.4 (3913.9) MB, 4.5 / 0.0 ms (average mu = 0.991, current mu = 0.990) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x2a42914841bd]
Security context: 0x281401b9e6c9 <JSObject>
1: decode [0x1c8f15ad00a9] [/media/Data/dev/btc-crawler/node_modules/bitcoin-protocol/src/types.js:~94] [pc=0x2a429178f88b](this=0x1c8f15acb299 <Object map = 0x736c200e801>,buffer=0xeeb6cf17c29 <Uint8Array map = 0x3d1fa97d04e9>,offset=4,end=0x25b4eaf822e1 <undefined>)
2: _transform [0x38503cda5d21] [/me...
FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory
1: 0x89c2f0 node::Abort() [node]
2: 0x89c33c [node]
3: 0xa8f05e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xa8f278 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xe7cad2 [node]
6: 0xf88847 v8::internal::HashTable<v8::internal::StringTable, v8::internal::StringTableShape>::New(v8::internal::Isolate*, int, v8::internal::PretenureFlag, v8::internal::MinimumCapacity) [node]
7: 0xf9a3c8 v8::internal::HashTable<v8::internal::StringTable, v8::internal::StringTableShape>::EnsureCapacity(v8::internal::Handle<v8::internal::StringTable>, int, v8::internal::PretenureFlag) [node]
8: 0xf9a58a v8::internal::StringTable::LookupKey(v8::internal::Isolate*, v8::internal::StringTableKey*) [node]
9: 0xfa03f4 v8::internal::StringTable::LookupString(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>) [node]
10: 0xf678aa v8::internal::LookupIterator::PropertyOrElement(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, bool*, v8::internal::LookupIterator::Configuration) [node]
11: 0x1112512 in the code, v8::internal::Runtime::GetObjectProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, bool*) [node]
12: 0x1112849 [node]
13: 0x1114f09 v8::internal::Runtime_KeyedGetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [node]
14: 0x2a42914841bd
型
types.js的第94行是decode函数的入口点,定义如下:
var buffer12 = struct.Buffer(12)
function decode (buffer, offset, end) {
var bvalue = buffer12.decode(buffer, offset, end)
for (var stop = 0; bvalue[stop] !== 0; ++stop);
for (var i = stop; i < bvalue.length; ++i) {
if (bvalue[i] !== 0) throw new Error('Found a non-null byte after the first null byte in a null-padded string')
}
return bvalue.slice(0, stop).toString('ascii')
}
型
2条答案
按热度按时间yeotifhr1#
你有一个错字!
正确的用法是
node --max-old-space-size=4096 somescript.js
4096在这种情况下是4gb,在你的情况下相应地调整一下...
运行
node --v8-options
以获得所有有效v8选项的列表,或选中this list of v8 flags6vl6ewon2#
在我的情况下,只是升级了mysql(下载并安装最新版本),因为数据库没有连接。所以我运行这些查询。
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new password '; 刷新特权;*
在mysql workbench或shell中运行此命令。
然后,您将停止得到这样的错误。