Runtime Flow blog (Understanding a control flow in a running .NET application)

September 11, 2011

Call stack depth limits

Filed under: Uncategorized — Sergey Vlasov @ 10:47 am

When viewing deep function calls in the Runtime Flow window you may hit a WPF layout recursion limit. To illustrate this problem I created a very simple application:

    class Program
    {
        static void Main(string[] args)
        {
            f(1);
        }

        static void f(int i)
        {
            if (i < 500)
                f(i + 1);
        }
    }

In Runtime Flow portable you can open maximum 58 recursive calls:

Maximum supported stack depth in Runtime Flow .NET 3.5

Maximum supported stack depth in Runtime Flow .NET 3.5


If you try to see more calls you get the following error:
Layout recursion limit reached WPF error

Layout recursion limit reached WPF error

The same problem exists when you view monitoring results in Visual Studio 2008/2005. In .NET 4.0 the layout recursion limit is increased from 255 to 4096. So in Visual Studio 2010 you can view much deeper stacks (though not 1024 deep due to other limitations).

I’ve created an additional Runtime Flow portable binary built for .NET 4.0 to enable more deep stack investigations:

Runtime Flow portable binaries for .NET 3.5 and .NET 4.0

Runtime Flow portable binaries for .NET 3.5 and .NET 4.0

If you have .NET 4.0 installed on the machine, it is now recommended to use RuntimeFlowPortable.NET40.exe instead of RuntimeFlowPortable.NET35.exe. It supports stacks up to 285 function calls:

Maximum supported stack depth in Runtime Flow .NET 4.0

Maximum supported stack depth in Runtime Flow .NET 4.0

Download link: Runtime Flow portable edition v1.3.1.

Advertisement

Create a free website or blog at WordPress.com.

%d bloggers like this: