Link to home
Start Free TrialLog in
Avatar of bigbangtech
bigbangtech

asked on

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.
Avatar of cj_1969
cj_1969
Flag of United States of America image

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
Avatar of bigbangtech
bigbangtech

ASKER

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 system.io.file.exists(path) 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 callssystem.io.file.exists 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,.

Opinions?
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.
ASKER CERTIFIED SOLUTION
Avatar of cj_1969
cj_1969
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial