所以,我最近有一个过于热心的循环,导致这个有趣的打印出现:
<--- 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
我修好了它并且它没有问题,但我实际上非常接近极限。我填充了一个充满数据的数组,主要是对填充数据进行平均分析。它实际上并不需要是完整的列表,所以这就是为什么我能够缩短循环并让事情变得正常。
但是打破一个循环并不总是理想的。我知道we can't really prevent a failed allocation,但它让我思考。 分配失败并且代码操作会在javascript中继续吗?
基本上,这种情况是否可以正确设置?
var a = 10;
var b = 2;
var c = OverAllocatingFunction(); // Everything would crash here
a = 5 - b; // Can we get here?