mscorlib 2.0.0.0 4.0.0.0 System.OutOfMemoryException

Unlike , 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 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 class for a code example.

This exception is not included in the .NET for Windows Store apps 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 instead.

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

- Constructor
  2.0.0.0
  4.0.0.0

  This constructor initializes the property of the new instance to a system-supplied message that describes the error, such as "Insufficient available memory to meet the expected demands of an operation at this time. Please try again later." This message takes into account the current system culture.

  The following table shows the initial property values for an instance of .

  Property

  Value

  null.

  The localized error message string.

  Initializes a new instance of the class with a system-supplied message that describes the error.

- Constructor
  2.0.0.0
  4.0.0.0

  The following table shows the initial property values for an instance of .

  Property

  Value

  null.

  The error message string specified in .

  Initializes a new instance of the class with a specified message that describes the error.

  The message that describes the exception. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
- Constructor
  2.0.0.0
  4.0.0.0

  An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the property. The property returns the same value that is passed into the constructor, or null if the property does not supply the inner exception value to the constructor.

  The following table shows the initial property values for an instance of .

  Property

  Value

  null.

  The error message string specified in .

  Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.

  The message that describes the exception. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
  The exception that is the cause of the current exception. If the parameter is not null, the current exception is raised in a catch block that handles the inner exception.