RuntimeHelpers.EnsureSufficientExecutionStack Method

Definition

Ensures that the remaining stack space is large enough to execute the average .NET function.

public:
 static void EnsureSufficientExecutionStack();
public static void EnsureSufficientExecutionStack ();
[System.Security.SecurityCritical]
public static void EnsureSufficientExecutionStack ();
static member EnsureSufficientExecutionStack : unit -> unit
[<System.Security.SecurityCritical>]
static member EnsureSufficientExecutionStack : unit -> unit
Public Shared Sub EnsureSufficientExecutionStack ()
Attributes

Exceptions

The available stack space is insufficient to execute the average .NET function.

Remarks

EnsureSufficientExecutionStack provides information about an artificially limited stack that preserves enough space for an exception to be raised and recovery action to be taken. The artificial stack limit is chosen by the common language runtime to ensure that enough space remains to throw an exception safely.

This method is useful in situations where stack overflow might occur as a result of unbounded recursion. It is intended for use in compiler services scenarios, although it can also be used safely in other development scenarios.

If the stack space is sufficient, the exception is not thrown, and most .NET types and members can still be called.

Note

This method is not part of the constrained execution region (CER) support, and should not be confused with the RuntimeHelpers.ProbeForSufficientStack method.

Applies to