I was just trying things in PowerShell and got an error about call depth being set to 1000 in some test recursive function. I looked on the Internet for some information and found that this is due to error handling in PowerShell (if I got it right):
The recursion depth limit is fixed in version 1. Deep recursion was causing problems in 64-bit mode because of the way exceptions were being processed. It was causing cascading out-of-memory errors. The net result was that we hard-limited the recursion depth on all platforms to help ensure that scripts would be portable to all platforms.
– Bruce Payette, co-designer of PowerShell
I found it here.
Also I found this exception page on MSDN that states this limit is configurable (but I didn’t find anything about how to do this) – see remarks section here.
How can this limit be set?
Using .NET Reflector, we can see in this snippet from the
System.Management.ExecutionContextclass code,that it is not possible to modify the hardcoded 100.
Again when looking at the code, there doesn’t seem to be a way around the default maximum call depth.