ASP.NET Tips: What to gather to troubleshoot - part 5 - OutOfMemoryException
So we already talked about what to gather when you are experiencing high memory. But what if you are actually getting a System.OutOfMemoryException? Here is how you capture a dump at the time you are running out of memory.
The following steps will configure DebugDiag to automatically capture the memory dump when the System.OutOfMemoryException occurs.
Before the issue occurs
A. Download DebugDiag:
====================
- Install the Debug Diagnostic tool
- The default installation location for the package is C:\Program Files\DebugDiag. It can be changed.
- Make sure any other monitoring and debugging tools are not running.
B. Create a Performance Monitor log:
====================================
- Expand Performance Logs and Alerts
- Right Click on Counter Logs
- Choose New Log Settings...
- Enter a descriptive name
- Note the log file location for later (or go to the Log Files tab and change the location)
- Click the Add button
- Click the All Counters and All Instances radio buttons
- Select the following from the Performance Object dropdown, being sure to Add each one as you select it:
- Process
- Thread
- Processor
- Memory
- .NET CLR Data
- .NET CLR Exceptions
- .NET CLR Interop
- .NET CLR Jit
- .NET CLR Loading
- .NET CLR LocksAndThreads
- .NET CLR Memory
- .NET CLR Networking
- .NET CLR Remoting
- .NET CLR Security
- ASP.NET
- ASP.NET Applications
- Click Close
- Click OK
For the ASP.NET counters, select the version that you are wanting to monitor. Ex. For 1.1 framework, select ASP.NET v1.1.4322 and ASP.NET Applications v1.1.4322.
Note: For more information on Performance monitor, see KB 248345
C. Configure server to capture OutOfMemoryException
===========================================
Add the following registry key. This was added to the .NET Framework so that a breakpoint exception will be thrown when an OutOfMemory condition occurs. This is documented in the following article:
820745 Failfast occurs when you experience an "out of memory" condition
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\
DWord: GCFailFastOnOOM
Value: 2
D. Configure DebugDiag
===================
Configure DebugDiag to capture the memory dump when the BreakPoint Exception is thrown and when the process stops.
- Open DebugDiag
- On the Rules tab, click Add Rule
- Select Crash and click Next
- Select All IIS Processes and click Next
- Click Advanced Exception Configuration
- Click Add Exception
- Select Breakpoint Exception, change Action Type to Full UserDump
- Click OK
- Click Save and Close
- Click Advanced Breakpoint Configuration
- Click Add Breakpoint
- Type KERNEL32!ExitProcess and change Action Type to Full UserDump
- Click OK
- Click Save and Close
- Click Next through the rest of the wizard
Inject LeakTrack.dll to capture native leak information:
- Click the Processes tab
- Right-click the ASPNET_WP.exe process (or w3wp.exe if running in IIS 6), select Monitor for leaks
After the issue occurs
The memory dump will automatically get captured when the OutOfMemoryException is thrown.
A. Stop the Performance Monitor log
===================================
In Performance Monitor:
- Right click on your log that is now listed under Counter Logs
- Choose Stop Log
Comments
Anonymous
May 19, 2008
You've been kicked (a good thing) - Trackback from DotNetKicks.comAnonymous
May 19, 2008
DebugASP.NETTips:Whattogathertotroubleshoot-part5-OutOfMemoryException.NETWhyuseth...Anonymous
May 19, 2008
Debug ASP.NET Tips: What to gather to troubleshoot - part 5 - OutOfMemoryException .NET Why use the EntityAnonymous
May 21, 2008
So now that I am done with all the individual posts, I thought I would wrap them all together. Anonymous
January 13, 2009
There are situations when we want to look closely at a process that is running in production environmentAnonymous
May 22, 2009
When the .NET Framework was first released, many developers believed the introduction of the garbageAnonymous
May 26, 2009
When the .NET Framework was first released, many developers believed the introduction of the garbageAnonymous
May 26, 2009
When the .NET Framework was first released, many developers believed the introduction of the garbage