RuntimeHelpers.EnsureSufficientExecutionStack Method


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

 static void EnsureSufficientExecutionStack();
public static void EnsureSufficientExecutionStack ();
public static void EnsureSufficientExecutionStack ();
static member EnsureSufficientExecutionStack : unit -> unit
static member EnsureSufficientExecutionStack : unit -> unit
Public Shared Sub EnsureSufficientExecutionStack ()


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


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.


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

Applies to