I try to perform some simulations and mathematical operations that are very recursive, and in some cases I overflow the call stack and get the signal EXC_BAD_ACCESS. It is not possible to change the algorithms to iterative form, as there is a lot of outdated code. And limiting the depth of recursion will not be useful, since memory usage is not deterministic.
Is there a way to determine the amount of stack so that I can cancel the operation gracefully?
Is it possible to implement a type of Stack Canary that I can constantly check is not overestimated?
source share