So, I recently had an overzealous loop that caused this fun print out to happen:
<--- Last few GCs --->
10472 ms: Scavenge 960.5 (998.3) -> 960.5 (998.3) MB, 0.0 / 0 ms (+ 1.0 ms in 1 steps since last GC) [allocation failure] [incremental marking delaying mark-sweep].
10641 ms: Mark-sweep 960.5 (998.3) -> 577.9 (615.7) MB, 169.6 / 0 ms (+ 1.0 ms in 2 steps since start of marking, biggest step 1.0 ms) [last resort gc].
10795 ms: Mark-sweep 577.9 (615.7) -> 577.6 (615.7) MB, 153.3 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
[Deleted the trace cause who cares]
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
I fixed it and it's a non-issue but I'm actually approaching the limit very closely. I'm populating an array full of data and mostly just taking an average-analysis of the populated data. It really doesn't need to be the complete list so that is why I was able to stop the loop short and have things be okay.
But breaking a loop short is not always ideal. I know we can't really prevent a failed allocation, but it got me thinking. Can an allocation fail and code operation continue in javascript?
Basically, is this scenario possible with the correct setup?
var a = 10;
var b = 2;
var c = OverAllocatingFunction(); // Everything would crash here
a = 5 - b; // Can we get here?