.NET OutOfMemory Exception

We have a .NET application in production for over a year. This is a help service, and the way it is written is that if it crashes for any reason, it will automatically restart. Until recently, it didn't give us headaches despite the heavy workload it handles on a daily basis, but now every time in the blue moon it crashes with the OutOfMemorey exception. After a reboot, it brings up the situation where it crashed and does whatever it is supposed to do, so the client doesn't care, but I would like to understand what is causing the crash.

So the question is, is there a way to investigate crashes without redeploying the application? What I would like to do is create a crash dump or whatever and then manually go through the dump trying to figure out which objects have eaten up all my memory. What tools would you suggest using to facilitate this task?

+2


source to share


1 answer


You can find the following article from MSDN:

Debugging production for .NET Framework applications

http://msdn.microsoft.com/en-us/library/ms954591.aspx

Although he discusses ASP.NET applications in detail, some of the techniques described are just as effective when parsing memory in services or stand-alone applications.

You can also use Perfmon to connect to a process and see if you are getting a lot of growth in Gen 1 or Gen 2 heaps - this usually indicates objects that are surviving too many garbage collections and creating pressure memory in your application. You can also look at the size of the Private Bytes metric - a growth there indicates that a lot of unmanaged memory is getting allocated to your process.

Perfmon's analysis is useful because it can show memory usage overtime and help determine if certain types of processing or transactions are responding to memory consumption.



If you can reproduce the issue in a test environment, there is an excellent memory profiler from the folks at Red Gate Software that can help pinpoint such issues in a fraction of the time it takes to unload memory.

There are several tools that can run in the background (eg DebugDiag) that periodically enable storage of memory dumps, or when certain events occur. You can read about them here:

http://blogs.msdn.com/sukeshak/pages/ddintro.aspx

http://blogs.msdn.com/tess/archive/2009/01/23/net-hang-analyzing-debug-diag-output.aspx

+4


source







All Articles