Configure an Application Pool to Recycle after Reaching Maximum Virtual Memory Usage (IIS 7)
Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista
If you notice a steady increase in the amount of virtual memory used on your server, you may have an application that reserves memory multiple times, and which fragments the memory heap. You can configure an application pool to recycle before reaching a certain virtual memory threshold. Initially, you should set the virtual memory threshold to be less than 70 percent of available virtual memory, and then monitor the memory usage of the worker process. You can adjust the setting if memory usage continues to increase.
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 virtual memory usage
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
Open IIS Manager. For information about opening IIS Manager, see Open IIS Manager (IIS 7).
In the Connections pane, expand the server node and click Application Pools.
On the Application Pools page, select an application pool, and then click Recycling in the Actions pane.
Select Virtual memory usage (in KB), and in the corresponding box type a memory value at which you want the application pool to recycle.
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 reaching a specified virtual memory threshold, use the following syntax:
**appcmd set config /section:applicationPools /[name='string'].recycling.periodicRestart.memory:**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 number of kilobytes of virtual memory after which to recycle an application pool. For example, to configure an application pool named Marketing to recycle after two thousand kilobytes of virtual memory, type the following at the command prompt, and then press ENTER:
appcmd set config /section:applicationPools /[name='Marketing'].recycling.periodicRestart.memory:2000
For more information about Appcmd.exe, see Appcmd.exe (IIS 7).
Configuration
The procedure in this topic affects the following configuration elements:
memory 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.Memory 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