System.InsufficientMemoryException Class

The exception that is thrown when a check for sufficient available memory fails. This class cannot be inherited.

See Also: InsufficientMemoryException Members

Syntax

public sealed class InsufficientMemoryException : OutOfMemoryException

Remarks

Unlike OutOfMemoryException, InsufficientMemoryException is thrown before starting an operation, and thus does not imply state corruption. An application can catch this exception, throttle back its memory usage, and avoid actual out of memory conditions and their potential for corrupting program state.

This exception is thrown by the System.Runtime.MemoryFailPoint.#ctor(int) constructor when you specify a projected memory allocation larger than the amount of currently available memory. Your program can catch the exception and either delay the task that needs the memory or execute it in smaller steps that require less memory.

See the System.Runtime.MemoryFailPoint class for a code example.

Note:

This exception is not included in the tp://go.microsoft.com/fwlink/?LinkID=247912 or the Portable Class Library, but it is thrown by some members that are. To catch the exception in that case, write a catch statement for OutOfMemoryException instead.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0