views:

386

answers:

2

I am just wondering why is restarting IIS 7 application pool consider a good practice? I know that it'll clean up orphan resources like threads or session state, but how does other web server deal with this kind of problem? Do java developer/admin have to restart weblogic/websphere/apache/tomcat every so often to clean up junk in memory?

+2  A: 

Typically it's used to compensate for bad programming. Sometimes yours, sometimes third parties depending on the libraries you are using.

And, as with all recommendations, it's best to look at your specific environment to see if it's really necessary before doing it.

Start with profiling the app. A simple way is to just let it run for a while under load. Look for things like does memory utilization settle down or does it continually grow?

If it keeps growing, you will need to set IIS to recycle every so often and go fix your app. If it grows to a point then settles down then you should be just fine. Make sure you test even the edge cases of your app.

Chris Lively
I agree. In my opinion this is an Administrative task and not for the programmer though there's an API for doing such things http://msdn.microsoft.com/en-us/library/microsoft.web.administration.applicationpool.aspx
Nissan Fan
A: 

With IIS it is possible to have non-managed code - the best example is a COM object - that don't behave well. As a result you can set your IIS to recycle processes periodically, to allow for the memory leakage that might occur with such code.

It's not necessary to do it though. You can eliminate the restart thresholds, if you prefer not to restart the processes.

If this idea doesn't exist in other servers, then it may be because other servers allow only managed code.

Cheeso