This morning I found the following in my inbox:
I had set my web servers running on IIS 6 to recycle if they hit 700 MB (Maximum used Memory).Can I run a report to know how many times per day or week the W3WP got recycled.Any suggestions please.Thanks in anticipation
The quick answer to your question is to use performance monitor:
So, there's the answer. But while we're on the subject I'd like to mention application restarts as well.
Application restarts may lead you think that your entire application pool recycled, while in fact it was only one of the applications hosted by the application pool that restarted. If this is getting confusing, then please remember that there's a difference between application pools and application. An application pool will consist of one or several worker processes and may host one or several applications.
There are two easy ways of monitoring application restarts:
This is probably the easiest, though you won't get too much additional information other than the fact that an application restart occurred. Here's what you do:
By altering the root web.config you can get an event for every application shutdown and start up. This is a good way to get more detailed information on why the application shut down.
Open up the root web.config, (located in the %WinDir%\Microsoft.NET\Framework\v2.0.50727\CONFIG directory,) locate the healthMonitoring.rules subkey and add the following:
Now when the application exited for an application-specific reason you'll get an event like this:
Event code: 1002 Event message: Application is shutting down. Reason: Configuration changed. Event time: 2/14/2008 10:00:41 AM Event time (UTC): 2/14/2008 9:00:41 AM Event ID: a1314c10a0c84222ae2d870d85308304 Event sequence: 18 Event occurrence: 1 Event detail code: 50004 Application information: Application domain: /LM/w3svc/1/ROOT/Test-1-128474532435626182 Trust level: Full Application Virtual Path: /Test Application Path: c:\inetpub\wwwroot\Test\ Machine name: JOHAN
As you can see the application shut down because the configuration changed. Note that you won't get an event if you manually kill the entire application pool in IIS manager, or similar. One thing that you will get, however, is the following event each and every time the application starts up again:
Event code: 1001 Event message: Application is starting. Event time: 2/14/2008 10:00:47 AM Event time (UTC): 2/14/2008 9:00:47 AM Event ID: 1f41fd3b17764330ac61804094b0abf0 Event sequence: 1 Event occurrence: 1 Event detail code: 0 Application information: Application domain: /LM/w3svc/1/ROOT/Test-1-128474532435626182 Trust level: Full Application Virtual Path: /Test Application Path: c:\inetpub\wwwroot\Test\ Machine name: JOHAN
So even if the application shut down for a reason that didn't generate an event, (IISReset, idle server, etc.) you'll at least see that for some reason it had to start up again.
/ Johan