How to restart IIS6 worker process (outofmemory exception)

Posted on 2007-07-23
Last Modified: 2010-08-05
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.
Question by:bigbangtech
    LVL 22

    Expert Comment

    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

    Author Comment

    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,.

    LVL 22

    Expert Comment

    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.
    LVL 22

    Accepted Solution

    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.
    LVL 1

    Assisted Solution

    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!).


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Logparser is the smartest tool I have ever used in parsing IIS log files and there are many interesting things I wanted to share with everyone one of the  real-world  scenario from my current project. Let's get started with  scenario - How do w…
    What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now