OutOfMemoryException

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
Bryan.Kelly
Posts: 2
Joined: Thu Nov 08, 2012 10:29 pm

OutOfMemoryException

Post by Bryan.Kelly » Thu Nov 08, 2012 10:52 pm

I am working on an issue at a client's site. We have a ASP.NET application that has been having OutOfMemoryExceptions and crashing the app pool. We setup DebugDiag and was able to get a memory dump of this occurring. I opened this up in .NET Memory Profiler 4.5 and I see a whole bunch of Unreachable objects. There are 13,979,140 of them (588,241,508 bytes). My understanding of what an "unreachable object" is that it is an object that was allocated at one point, but is no longer reachable by a root.

My understanding of what happens when an OutOfMemoryException occurs is that a full GC is done before that exception is thrown. It seems to me if that would have happened, there would have been a lot of memory cleared up and the exception could have been avoided.

Anyone have any thoughts?

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Re: OutOfMemoryException

Post by Andreas Suurkuusk » Fri Nov 09, 2012 1:17 pm

What version of .NET Framework is installed at the client's site?

If you import a memory dump that is created on a system that doesn't have .NET Framework 4.5 installed, the profiler will fail to identify the finalizer queue as a root for instances that are waiting to be finalized. So it is possible that the unreachable instances are instances that are waiting to be finalized. If you have a finalizable object that gets stuck in the finalizer, this will prevent other finalizable object from being finalized.

If the application is running under .NET Framework 4.0, you can get more information about finalizable instances if you install .NET Framework 4.5 on the machine. The application can still run under .NET Framework 4.0.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Bryan.Kelly
Posts: 2
Joined: Thu Nov 08, 2012 10:29 pm

Re: OutOfMemoryException

Post by Bryan.Kelly » Fri Nov 09, 2012 3:54 pm

Looks like I wrote my original post too quickly. I forgot to mention that the memory dump is from a process running .NET 1.1.

That makes sense about the Finalization queue, but it seems like there are a LOT of objects. I have a hard time believing they are all waiting for finalization.

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Re: OutOfMemoryException

Post by Andreas Suurkuusk » Mon Nov 12, 2012 7:32 am

.NET Framework 1.1 is no longer supported by .NET Memory Profiler 4.x. To profile .NET Framework 1.1 applications, I recommend that you use .NET Memory Profiler 3.5 instead. However, as you noticed it is still possible to import .NET 1.1 memory dumps, but this is not something we have tested with the latest version.

If an instance is stuck in the finalizer queue, any instances it can reach will also be kept alive by the finalizer queue, so the total number of instances kept alive by the finalizer queue can grow very quickly.

It is usually pretty easy to find out whether the finalizer has hung by attaching a debugger to the process and looking at what code the finalizer thread is executing.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests