开发者

System Out Of Memory Exception in Production Server

开发者 https://www.devze.com 2022-12-12 15:26 出处:网络
We have .net application installed on production server. It is using .net FrameWork 3.0 on windows server 2003 with RAM 4 GB.

We have .net application installed on production server. It is using .net FrameWork 3.0 on windows server 2003 with RAM 4 GB. But there is a problem in application while running sometimes it throws system out of memory exception. I am very frustrating with this. Also I am unable to simulate the issue. I had checked all the possibilities which can cause the problem but didn’t get any thing which solve the issue

I checked on production server event log found the Out Of Memory Exception also INVALID VIEW STATE logs are there. Look at the following event log which may help to find solutions.

Exception information: 
    Exception type: HttpException 
    Exception message: Invalid viewstate. 
Request information: 
    Request path: /zContest/ScriptResource.axd 
    User: LisaA 
    Is authenticated: True 
    Authentication Type: Forms 

Thread information: 
    Thread ID: 10 
    Is impersonating: True 
    Stack trace:    at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType)
   at System.Web.UI.Page.DecryptString(String s)
   at System.Web.Handlers.ScriptResourceHandler.DecryptParameter(NameValueCollection queryString)
   at System.Web.Handlers.ScriptResourceHandler.ProcessRequestInternal(HttpResponse response, NameValueCollection queryString, VirtualFileReader fileReader)
   at System.Web.Handlers.ScriptResourceHandler.ProcessRequest(HttpContext context)
   at System.Web.Handlers.ScriptResourceHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynch开发者_如何学运维ronously)
------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------
Event code: 3005 
Event message: An unhandled exception has occurred. 
Process information: 
    Process ID: 5388 
    Process name: w3wp.exe  
Exception information: 
    Exception type: OutOfMemoryException 
    Exception message: Exception of type 'System.OutOfMemoryException' was thrown. 
------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------

Please help me out on this


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: First, 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:


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.


Finding out the memory limit and trying to increase that is less useful, as you don't even know how the memory is ate up by the application, or if there is any possibility to use less memory.

This Microsoft post shows what are the most common causes, and of course resources on how to further analyze the memory usage,

http://blogs.msdn.com/b/webtopics/archive/2009/05/22/troubleshooting-system.outofmemoryexceptions-in-asp.net.aspx


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.


Try: IIS Manager -> ASP -> Limits Properties -> Maximum Requesting Entity Body Limit.

I increased the limit. It worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消