Compartir a través de


Configure an Application Pool to Recycle after Reaching Maximum Used Memory (IIS 7)

Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista

If you have an application that leaks memory, you can configure an application pool to recycle when the memory that is used by the W3wp.exe process reaches a configured threshold. Typically, you should set this value to be less than 60 percent of the available physical memory on the server.

Prerequisites

For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see Application Pools Feature Requirements (IIS 7).

Exceptions to Feature Requirements

  • None

To configure an application pool to recycle after reaching maximum used memory

You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.

User Interface

To use the UI

  1. Open IIS Manager. For information about opening IIS Manager, see Open IIS Manager (IIS 7).

  2. In the Connections pane, expand the server node and click Application Pools.

  3. On the Application Pools page, select an application pool, and then click Recycling in the Actions pane.

  4. Select Private memory usage (in KB), and in the corresponding box type a memory value at which you want the application pool to recycle.

  5. Click Next, select the events that should be logged when an application pool recycles, and then click Finish.

Command Line

To configure an application pool to recycle after it uses a specified amount of private memory, use the following syntax:

**appcmd set config /section:applicationPools /[name='string'].recycling.periodicRestart.privateMemory:**uint

The variable string is the name of the application pool that you want to configure. The variable uint is an unsigned integer, which specifies the amount of private memory (in kilobytes) after which you want the application pool to recycle. For example, to configure an application pool named Marketing to recycle after it uses two thousand kilobytes of private memory, type the following at the command prompt, and then press Enter:

appcmd set config /section:applicationPools /[name='Marketing'].recycling.periodicRestart.privateMemory:2000

For more information about Appcmd.exe, see Appcmd.exe (IIS 7).

Configuration

The procedure in this topic affects the following configuration elements:

privateMemory attribute of the <periodicRestart> element under <recycling>

For more information about IIS 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.

WMI

Use the following WMI classes, methods, or properties to perform this procedure:

  • ApplicationPool.Recycling.PeriodicRestart.PrivateMemory property

For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS WMI Provider Reference on the MSDN site.

See Also

Concepts

Configuring Recycling Settings for an Application Pool (IIS 7) Managing Application Pools in IIS 7