How to create a dump on an OutOfMemoryException.
So, you are running your web application in IIS and intermittently you get an OutOfMemoryException.
Basically you get something like this in the browser and\or you see this in the event viewer:
Exception of type 'System.OutOfMemoryException' was thrown.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
Process information:
Process ID: xxx
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: OutOfMemoryException
Exception message: Exception of type 'System.OutOfMemoryException' was thrown.
So, you log a call with support and we ask you to take a memory dump on this exception. So how do you do that?
Step 1.:
Create the following key in the registry where GCBreakOnOOM is DWORD and the value is 2:
Key Name: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework
…
Name: GCBreakOnOOM
Type: REG_DWORD
Data: 0x2
Step 2:
Download and install ”Debug Diagnostic Tool v1.2”
https://www.microsoft.com/download/en/details.aspx?id=26798
Step 3:
Start ”Debug Diagnostic Tool v1.2” and select to “Add Rule..” if that dialog do not show on start up.
Select Crash as the rule type and then Next, then select “A specific IIS web application pool” (providing you know what app pool is getting the OOM) and then Next.
Select the “Exceptions…” button under the “Advanced Settings” and select “Add Exception…” and select “80000003” (Breakpoint Exception) from the list to the left.
Set the “Action Type” to be “Full Userdump”. Then OK and “Save & Close” and Next. Change the “Userdump Location” to, for example, C:\Dumps.
Do not forget to select “Activate the Rule now” if it is not selected.
Step 4:
Run the web application until you get the OutOfMemoryException.
And that is it. You should now have a dump file called something like this at the location you specified, for example;
w3wp__DefaultAppPool__PID__19912__Date__02_14_2012__Time_03_33_40PM__831__First Chance Breakpoint Exception.dmp
This is what you should .zip and send to us.
Once this is done, just remove the rule from Debug Diag and the key in the registry otherwise it will create dumps for future OutOfMemoryExceptions.
More on this and some information on OutOfMemoryExceptions here:
Catching a memory dump on system.outofmemoryexception
How to Troubleshoot Out of Memory Issues (System.OutOfMemoryException) in ASP.NET
https://support.microsoft.com/?kbid=2020006
Troubleshooting System.OutOfMemoryExceptions in ASP.NET
Investigating Memory Issues
https://msdn.microsoft.com/en-us/magazine/cc163528.aspx
Large Object Heap Uncovered
https://msdn.microsoft.com/en-us/magazine/cc534993.aspx
How does the GC work and what are the sizes of the different generations?
Who is this OutOfMemory guy and why does he make my process crash when I have plenty of memory left?
https://blogs.msdn.com/b/tess/archive/2005/11/25/496898.aspx
OutOfMemoryException Class
https://msdn.microsoft.com/en-us/library/System.OutOfMemoryException.aspx