RuntimeHelpers.EnsureSufficientExecutionStack Method ()

.NET Framework (current version)

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

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

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

public static void EnsureSufficientExecutionStack()

Exception Condition

The available stack space is insufficient to execute the average .NET Framework 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 Framework 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.

Universal Windows Platform
Available since 10
.NET Framework
Available since 4.0
Return to top