OutOfMemoryException

When the managed heap becomes full, the garbage collector will ask the operating system for more virtual memory. When this request fails, the OutOfMemoryException is thrown. This exception cannot be caught by application code and will terminate your program on the spot. One reason you cannot catch the exception is that it takes immense powers to deal with such an exception without allocating more memory while doing so. In addition, no guarantees are made about the execution of finally blocks and finalizers in out-of-memory conditions because they may allocate memory on their own. Luckily, outstanding open handles to Win32 resources will be closed either way because the operating system takes care of this upon program termination. ...

Get C# 4.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.