How to restart IIS6 worker process (outofmemory exception)

We most likely have a memory leak in our asp application, but it may be some time before we can effectively address this problem.

Every so often, our website hangs and shows a page stating their is an outofmemory exception.

The problem is that IIS does not restart the worker process because it is responding to the health pings. It's not completely crashed which is how it's basically described in MS KB.

If the worker process completely died, it would be restarted because there would be no response to a ping.

What we need, is a way to detect when the web server is showing an outofmemoryexception to the website visitor, and recyle the affected worker process(we have two) all automatically of course.
Who is Participating?
cj_1969Connect With a Mentor Commented:
As an alternative ... you could write an app that requests a page from the server and checks for the error.  If you find it then do a kill on the process by name and then start it up again, or let it start up again depending on the process.
My guess is that without a program to request a page and parse it to check for the specific error you are not going to find a way to just monitor the process and "know" when it is hung.
That said ... what about a timed process, just recycle it every hour or two (or what ever time frame will work for you).  There are a few ways you can recycle the IIS process and any apps it has spawned.

As a starting point if you need to kill specific named apps then you can use hte PSTools app pskill.exe and then either restart the IIS process or you can stop and start a website with something like net use or iisweb.vbs
bigbangtechAuthor Commented:
We're using Able Commerce ASP for our shopping website, and recycling the process every few hours would not help, especially during peak usage hours. When the worker process starts, it takes a long time to build a cache of all our product directories, recycling every so often could restart the healthy thread when it's working fine. Setting an idle-timeout in IIS doesn't work either because the worker processes are never idle, even when they are hung with the outofmemory exception.

Since restarting the process when it's hung doesn't seem feasible, I'd like to get an opinion on one of our possible memory leaks(suspected)

We have category.aspx which can load and display 50 categories or products and we have product.aspx which loads and displays a single product.

In both files, for each category or product, we load a a JPG, but first we check to see if the file exists, if not, we load a "missing image" jpg

We're using to check if the files exist and are wondering what kind of performance hit this can place on the server, and whether or not this may be causing a leak somehow.

Let's say we have 100 simultaneous website visitors, and they each view category.aspx which checks 50 jpgs if they exist, and then loads them or a dummy.

That's 5,000 in a very short period of time.

Also, looking at MSDN, I've seen posts state that file.exists first tries GetFileAttributesEx to check the file, and then the slower FindFirstFile if anything but File Not Found is returned,.

50 categories isn't that much ... even with a significant amount of product under each one ... have you thought of creating a DHTML page with the data and parsing the information on the client side?
If going this route you could rebuild the page on a regular basis to keep the images and content updated ... this would remove a significant load on your server.
rhettlConnect With a Mentor Commented:
Are you sure it is the IIS process that has the memory problem, or is another process consuming the memory? I am curious to know whether you have run any memory profiling on the server - like, how much memory is available and how much is IIS using?

You mentioned the Able Commerce application - some questions about this app, (assuming you have any knowledge of this application and its operations):
Is this running as .NET 1 or 2.0?
What kind of database connection does this use?
Do you have this running in a testing / development environment? I have seen this application behave very differently on different servers. One we are testing right now runs at about 150MB on dev and 1,200MB to 1,500 on production (idle!).

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.