I wanted to understand the max stack frames / size in better detail.
function computeMaxCallStackFrames() {
try {
//
// <Variable part here>
//
return 1 + computeMaxCallStackFrames();
} catch (e) {
// Call stack overflow
return 1;
}
}
computeMaxCallStackFrames() // 5447 on Chrome 58.0.3029.110, Mac 10.11
Changing // <Variable part here>
to:
Test case 1:
var a = 1;
// computeMaxCallStackFrames() => 5220
Test case 2:
var a = 1;
var b = 2;
// computeMaxCallStackFrames() => 5011
Test case 3:
var a = 1;
var b = {};
// computeMaxCallStackFrames() => 5011 (no change from `var b = 2;`)
Test case 4:
var a = 1;
var b = {c: 3};
// computeMaxCallStackFrames() => 5010
My question is why Test case 4
changes at all and why it changes by 1 fewer stack frames.
** edit ** any relevant links to v8 source would be fantastic. Even just showing where stack size memory limit is set would be great intro. Apologies for not asking this by the time Andreas Rossberg and jmrk already left their great answer and comments respectively.