I was having issues with a website on my server which was occasionally losing session state.

I narrowed the problem to IIS7, so I added a method to the Application_Start event (it's an ASP.Net MVC app), which emails me every time the application is started and re-deployed the site about a week ago. I've been getting the 'startup' email every 26ish hours since.

So, I'm wondering why IIS would be restarting the app.


This is controlled by the recycling feature of the Application Pool the site resides in most likely. You can tweak this to recycling at set times or at longer intervals.


Have you taken a look at this thread?


While it doesn't seem to have an immediate answer to your question it does appear that this is not an uncommon problem.

It also contains other links which may prove useful.

  • 2
    I skimmed then. Just re-read it. Have a call in to the hosting company to find out what the virus scanning schedule is. Per this article: blogs.msdn.com/tess/archive/2006/08/02/…
    – RKitson
    Jul 28 '09 at 22:27
  • Yeah, it sounds too "perfect" to be coincidence. Several theories in that thread so I was hoping one of them might lead you in the right direction. :-)
    – KPWINC
    Jul 28 '09 at 22:32

Will and Shufler were both right. The application pool was recycling itself.

I discovered this by selecting the pool from the list of Application Pools and clicking the 'Recycling...' button. That screen gives you a 3 options for recycle intervals: a set time interval (minutes), a fixed number of requests, or at specific times. And it appears that you can use all 3 in concert. You also have 2 options for Memory thresholds, that once hit will cause a recycle: Virtual memory usage (in KB) or Private memory usage (in KB).

Turns out, the pool was set to recycle itself every 1560 minutes.

  • I've seen this before where an app recycles due to memory use, but I've rarely seen it scheduled. Did your host have that set for a particular reason? Jul 29 '09 at 2:26
  • 1
    Was the default setting. It was an Application Pool that I had just added to IIS myself.
    – RKitson
    Jul 29 '09 at 21:49

Every 26 hours? That sounds like an application pool that is automatically restarting for the purposes of freeing memory.

  • I also thought of app pools as soon as I read the question.I still have to wonder why that would be necessary? Is that to deal with memory (or other resource) leaks in IIS or Windows, or is it the expectation that the apps the user writes will have leaks. I don't believe Apache or other Unix servers do this kind of thing as a matter of course. So I am left wondering.
    – railmeat
    Jul 28 '09 at 22:28
  • 1
    Garbage collection is a big reason. My primary experience with app pools is with SharePoint. SharePoint code is unmanaged which most .NET developers are aware of. This results in the app pool consuming memory steadily throughout the day. The best practice for SharePoint is in fact to recycle the pools once a day (or more if you can afford it). The catch of course, is that all sessions and connections are dropped hard.
    – shufler
    Jul 28 '09 at 22:45
  • 1
    That is to say, most .NET developers starting with SharePoint are unaware of (in my experience)
    – shufler
    Jul 28 '09 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.