RuntimeHelpers.ProbeForSufficientStack Method


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.

 static void ProbeForSufficientStack();
public static void ProbeForSufficientStack ();
static member ProbeForSufficientStack : unit -> unit
Public Shared Sub 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.

Applies to