我正在尝试运行以下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语句为真的情况下运行它。
我收到以下错误:
< ---最后几个GC --->
11450 ms:Mark-sweep 1388.5(1433.0) - > 1388.5(1445.0)MB,834.3 / 0.0 ms(自标记开始以来63步中+ 0.0 ms,最大步长0.0 ms)[分配失败] [清除可能不成功]。 12374ms:Mark-sweep 1400.2(1445.0) - > 1400.3(1445.0)MB,910.6 / 0.0 ms(自标记开始以来,188步中+ 0.1 ms,最大步长0.0 ms)[分配失败] [清除可能不成功]。
<--- 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]