6

I need to determine WHY the application pool is recycling. (its for no obvious reason)

Is there any way to determine this inside of the application_end sub in the global.asax file?

I have put some basic logging in there, so I know WHEN its shutting down, but I cannot tell why.

(and its nothing obvious... it just seems like every couple of requests certain operations cause the application to end. I have turned off every normal reason for recycling such as time outs, memory checks, etc, etc, etc. Same code is working fine on a different server, so I am sure its something wrong with this setup, but what?...)

  • Perhaps I should clarify... I believe the App Pool is recycling for these reasons: 1) The data in the Application hash is going away. IN otherwords if I write to Application("foobar") = "bloz" then on the next http post Application("foobar") is empty. 2) I am logging calls to Application_End. However I guess I don't know if that really means the app pool is recycling or what. – Mitch Van Duyn Apr 03 '11 at 19:29

3 Answers3

6

You don't have to incur overhead to add custom logging, ASP.NET 2.0 health monitoring does the job for you. You can add the following configuration which will log events in the eventlogs with information why Application pool is restarted.

To turn ASP.NET health monitoring ON, you can edit the "master" web.config file, normally found in %systemroot%\microsoft.net\framework\v2.0.50727\config.

  • First, look for <healthMonitoring> in the master web.config

  • Inside the healthMonitoring node, find the <rules> node

  • Inside rules, add the following:

    <add name="Application Lifetime Events Default"       
         eventName="Application Lifetime Events"       
         provider="EventLogProvider"       
         profile="Default"       
         minInstances="1"       
         maxLimit="Infinite"       
         minInterval="00:01:00"       
         custom="" /> 
    

Reproduce the issue and look in the Application event log fpr a source of ASP.NET 2.0. This should log why application pool is recycled.

KyleMit
  • 30,350
  • 66
  • 462
  • 664
amit
  • 2,093
  • 16
  • 10
  • It seemed like some instructions were missing above? At any rate see my comments above. Its really strange I see events for when I manually recycle the apppool but nothing else. – Mitch Van Duyn Apr 03 '11 at 19:28
  • 1
    Thanks. This worked. The problem was an idiot mistake on my part. Accidentally was creating files on the fly in the AppCode directory which was causing the app to recompile. Your answer helped. Thanks – Mitch Van Duyn Apr 03 '11 at 21:47
0

Try looking in the EventLog. When the app pool recycles, there is an entry written to the log along with the reason.

The following link describes the errors codes you'll see in the eventlog for IIS 7.5 http://technet.microsoft.com/en-us/library/dd349270(WS.10).aspx

Naraen
  • 3,240
  • 2
  • 22
  • 20
  • Nope... I have followed all the instructions already, and turned on all the checkboxes on iis recycling. I do not see any events except when I do a manual recycle. – Mitch Van Duyn Apr 03 '11 at 19:27
0

If there are not already log entries in your troubled machine's event viewer, you can modify IIS to log all app pool recycles.

Article from Microsoft on how to do it is found below

http://support.microsoft.com/kb/332088

Pepto
  • 1,434
  • 10
  • 13
  • Already had done this, and there are no events! I do see events for when I manually recycle the app pool, but nothing about any other recycles. – Mitch Van Duyn Apr 03 '11 at 19:25