Routine.run | stackSize & quant

Hi, can anyone quickly explain the meaning of argument values stackSize and quant in Routine.run?

I’m mostly interested in the definition of stackSize, I’ve yet to see it’s meaning documented anywhere.

The stack size is the size of the stack used internally by the interpreter for code execution. A smaller stack saves memory but limits recursion depth.

In general, you don’t need to mess around with the stack size unless you are running into stack overflow situations, which are rare.

hjh

Thanks James,

…since a stackSize of 512 seems to be the default value in all cases across the language, for the sake of our understanding, could you or someone else provide a classic example of how to overload the stack with a single fork or Routine ?

Perhaps highlighting ‘recursion depth’ would be excellent.

I did spend some time at this but failed to reproduce a stack overflow. Not quite interested in expending much more time on a “just for curiosity” question.

One thing I found while trying to understand why a simple recursion case wasn’t hitting the stack limit is that the SC backend enforces a minimum stack size of 512. You can extend it for special cases but you can’t make it smaller. So you won’t hit a stack overflow unless the call stack is extremely deep or your code has an infinite recursion bug.

hjh

1 Like