【发布时间】:2017-10-10 21:05:30
【问题描述】:
我正在尝试运行以下 while 循环,但由于某种原因出现 JS 堆内存不足错误:
while( typeof(apiResults[0].league.season.eventType[0].events[0].pbp[i].pbpDetails[p]) == 'undefined') {
//create time delay of one second
setTimeout(function(){
//put code to run after delay here
if( typeof(apiResults[0].league.season.eventType[0].events[0].pbp[i+1].pbpDetails[0]) != 'undefined') {
//this will run if the next inning has come through
i = i+1;
p = 0;
}
//this will also pass the while loop and go down to the actual code
}, 3000);
}
我知道逻辑有缺陷,但现在我只在 if 语句为真的情况下运行它。
我收到以下错误:
11450 ms: Mark-sweep 1388.5 (1433.0) -> 1388.5 (1445.0) MB, 834.3 / 0.0 ms (+ 0.0 ms in 63 steps in 63 steps since the start of marking, max step 0.0 ms) [分配失败] [清除可能不会成功]。 12374 毫秒:标记扫描 1400.2 (1445.0) -> 1400.3 (1445.0) MB,910.6 / 0.0 毫秒(自标记开始以来的 188 步中 + 0.1 毫秒,最大步长 0.0 毫秒)[分配失败] [清除可能不会成功]。
<--- JS stacktrace --->
Cannot get stack trace in GC.
FATAL ERROR: MarkCompactCollector: semi-space copy, fallback in old gen Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
【问题讨论】:
标签: javascript node.js