Asp.Net Out of Memory Exceptions and <gcServer=false /> setting

Share on Facebook

This was such a life saver, I had to quickly document it here to save someone else the trouble. To begin with I am surprised, there are not that many hits on google about this particular setting in the aspnet.config file which can continously crash your server over and over.

This is the issue, I maintain an Asp.Net 2.0 web application which runs in its own application pool on a 64 bit multi-processor virtual server hosting space. The KEY here is the multi-processor bit. Apparently, the .Net Common Language Runtime (CLR) uses a server garbage collector in such environments which allocates a separate garbage collector instance for each processor's separate memory heap. This can very quickly result in excessive memory usage during garbage collection and eaily bring the server down and start displaying Server Unavailable messages to clients.

Well, that is the issue, what of the solution?. As it happens, there is a very simple solution. To workaround this behavior, configure the CLR to use the Workstation garbage collector:1. Open the Aspnet.config file in Notepad.exe. The file is located at %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\Aspnet.config for .NET Framework 2.0 and at %SystemRoot%\Microsoft.NET\Framework\v1.1.4322\Aspnet.config for .NET Framework 1.1.2. In the section httpRuntime, add <<gcServer="false" />> (only one set of angle brackets!!) 3. Save the Aspnet.config file.

 

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkListkick it on DotNetKicks.comTwitThis

Comments

March 5. 2009 12:45 PM

chris

Nice one, Mike.
This fixed my ongoing asp.net application pool crashes.

You seem to be the only person on the internet who knows about this.

Ireland chris

March 9. 2009 03:34 AM

mike

Chris,

Happy to hear it helped you out. That was the compelling reason for sharing it, and thanks for the feedback!

United Kingdom mike

April 9. 2009 11:36 AM

UK Franchises

Hey, just checking out the blogengine.net platform...  Seems pretty nice.  What is the backend like?

Cheers

Matthew

United Kingdom UK Franchises

April 9. 2009 09:59 PM

miketeye

Very solid architecture. Supports both xml and sql server database as data store. very carefully thought out system all through. You will appreciate the design descisions if you dare to dive into the system. Works very well if all you want to do is blog. Very well supported extensions system with extensions to support all kinds of stuff from download counter to syntax highlighting.

hope this gives you an idea of the system in a nutshell.

United Kingdom miketeye

April 17. 2009 06:46 PM

Group Leadership

You did indeed save me the trouble! Thanks for documenting it!

United Kingdom Group Leadership

April 28. 2009 05:27 AM

miketeye

Oatis,

Thanks for the kind words. Glad it helped you out!

United Kingdom miketeye

June 22. 2009 07:52 PM

Tukang Nggame

nice article, thanks for taking the time to sharing this with us

United States Tukang Nggame

June 29. 2009 06:29 AM

Vivek

Hi,

We have issue of w3wp.exe using maximum memory usage on dedicated server. If we add gcServer="false" to app.config file will it help to reduce memory usage and clear all garbage memory.

We have other sites also on same server, will that reflect on all site on only one site.

Vivek Shrivastav

India Vivek

July 1. 2009 12:32 PM

miketeye

Vivek,

If the dedicated server is a multiprocessor machine, then using the gcServer=false setting as explained in the post should really reduce the memory usage. The gcServer=false setting is applied in the aspnet.config file, not the (app.config or web.config), so the setting applies to all sites running on the .Net framework on the server.

That is my understanding.

United Kingdom miketeye

Comments are closed

About Me

When not scratching my head for solutions to software challenges, I spend my time playing with my little boy - Michael Jnr.

Quotations

"Success is the ability to go from one failure to another with no loss of enthusiasm."
Sir Winston Churchill

Donate with PayPal - it

Calendar

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2005 - 2010

Search