I have written a tiny recursive bit of F# code to see how many levels of recursion I can fit onto the stack under .NET/Mono. It just prints the recursion depth whenever it i
This code gets around the mono limit. It is useful for dfs in competitive programming.
public static void IncreaseStack(ThreadStart action, int stackSize = 16000000)
{
var thread = new Thread(action, stackSize);
#if __MonoCS__
const BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Instance;
var it = typeof(Thread).GetField("internal_thread", bf).GetValue(thread);
it.GetType().GetField("stack_size", bf).SetValue(it, stackSize);
#endif
thread.Start();
thread.Join();
}