I am attempting to run the following while loop, but for some reason am getting a JS heap out of memory error:
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);
}
I know the logic is flawed, but right now I am only running it in instances where the if statement will be true.
I receive the following error:
<--- Last few GCs --->
11450 ms: Mark-sweep 1388.5 (1433.0) -> 1388.5 (1445.0) MB, 834.3 / 0.0 ms (+ 0.0 ms in 63 steps since start of marking, biggest step 0.0 ms) [allocation failure] [scavenge might not succeed]. 12374 ms: Mark-sweep 1400.2 (1445.0) -> 1400.3 (1445.0) MB, 910.6 / 0.0 ms (+ 0.1 ms in 188 steps since start of marking, biggest step 0.0 ms) [allocation failure] [scavenge might not succeed].
<--- 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]