Tracking .NET Out-Of-Memory errors

Add the following registry key:
HKEY_LOCAL_MACHINESOFTWAREMicrosoft.NETFramework

Value name: GCFailFastOnOOM
Value type: REG_DWORD
Value data: 4

The value of “4” writes an event message that includes the size of the allocation that failed and the number of bytes in use. A value of “1” simply logs an event in the Application event log. A value of “2” allows a debugger to be attached.

Use the “4” option to grab a dump, then examine the dump for severe fragmentation of the heap, or an attempt to allocate a huge object.