A: 

This is just a total shot in the dark, but is there some exception logging/mananagement haping and is it possible that an exception is being thrown from within the exception management framework? If so it would throw the application into an infinite loop which results in an out of memory exception.

When an out of memory exception follows some other exception this is usually the first place I look.

James Conigliaro
A: 

Take the error message at face value. It's saying that memory is exhausted. The most obvious reason for this is that your process has been growing in size over time. So what monitoring capabilities do you have to verify that this is the case?

Assuming that this is what is happening then there are two possibilities:

  1. your app is deliberately growing - for example you cache more and more data and eventually have used so much memory that there's no space to work in
  2. there is a memory leak, could be in the app, could be in libraries that you are using.

Finding such a problem by simply reviewing code is like sorting a haystack one strand at a time looking for a needle. You need tools. A quick Google for ".net memory leak detection" reveals plenty of such tools.

djna
1. I am using session to hold the values.. but that isn't big size.I have 4 GB RAM .2. I am using so Telerik control which embed javascript libraries in the view source like axd files ....
Sachin Gupta
2 is more likely. Strongly suggest you track the size of process over a perions of hours and determine if it's growing. If it is, then get a memory leak analyzer tool of some sort
djna
A: 

I've found that this is an issue related to with .NET memory management on IIS allocated to the large object heap and application pool memory recycling settings.

On 32 bit servers with 1GB or less of physical memory the server will default memory recycling at 60% of physical memory usage which will be about 600MB. Above 600MB you will notice a significant increase in outofmemoryexceptions by microsoft's own admission.

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

"A memory limit of 60% of physical RAM is recommended to avoid paging, especially when a new process replaces the old one due to excessive memory consumption. ..... It is important to adjust the memory limit on machines with large amounts of physical RAM, so that the cache memory manager and process recycling function properly. For example, assume you have a server with 4 gigabytes (GB) of physical RAM that is using the default memory limit. This is a problem. Sixty percent of physical RAM is 2.4 GB, which is larger than the default virtual address space of 2 GB. So what should the memory limit be set to? ...... There are a couple things to consider: F**irst, the likelihood of experiencing an OutOfMemoryException begins to increase dramatically when "Process\Virtual Bytes" is within 600 MB of the virtual address space limit** (generally 2 GB), "

With 1GB of physical memory the default settings will be ok, but with greater than 1GB you will need to make some adjustments to app pool memory recycling settings or change appropriate metabase settings.

Other related articles:

Richard Fremmerlid - MCPD

related questions