RuntimeHelpers.ProbeForSufficientStack Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Probes for a certain amount of stack space to ensure that a stack overflow cannot happen within a subsequent block of code (assuming that your code uses only a finite and moderate amount of stack space). We recommend that you use a constrained execution region (CER) instead of this method.

Namespace:   System.Runtime.CompilerServices
Assembly:  mscorlib (in mscorlib.dll)

public static void ProbeForSufficientStack()

This method is used by the constrained execution region (CER) infrastructure when running in hosts that are resilient to stack overflow such as Microsoft SQL Server and Microsoft Exchange Server. This method currently probes for 48 KB of stack space on the x86 platform, but the exact amount may change over time and may vary on other platforms.

This method is also used by compilers.

Instead of using the ProbeForSufficientStack method, you should use a standard CER. That is, if you are planning to use a moderate amount of stack space, call the RuntimeHelpers.PrepareConstrainedRegions method immediately before your try/finally or try/catch block. If you are calling a recursive method or plan to use a lot of stack space, you must use the RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup method.


requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

.NET Framework
Available since 2.0
Return to top