Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

.NET

Process Recycling and Its Triggers


All applications created to run for a potentially endless time are subject to the same big issue—memory leaks. It can be taken as a matter of fact that, on the average, all applications lose some bits of memory. This may not be a problem if the application runs for short sessions; it becomes a significant hurdle for applications that have to be up 24x7. ASP.NET applications just fall in this category. Aware of this statistic, designers of ASP.NET implemented a feature named "application restart" or process recycling. Simply put, application restarts are events in the lifetime of a deployed application that cause the worker process to kill the process and restart it. By killing the process, all cached information is lost, but at the same time any leaked memory is recovered. The worker process sets up an automatic system that periodically pings the application to ensure it is in health and restarts it if it detects the application is too slow in responding. There are a few reasons why an ASP.NET application can be restarted. Let's briefly review them.

The most common reason is that an application may get to consume more than a certain share of virtual memory. When this happens, the application is killed and restarted. The critical threshold of virtual memory is configurable and set to 60% by default. You should manage this parameter and ensure that it never exceeds the 800 MB value. You configure recycling through the Properties box of the Application Pool section of your IIS manager snap-in.

In addition, the ASP.NET runtime implements a good deal of checks and automatically restarts an application in a number of situations. For example, the application restarts after reaching the maximum limit of dynamic page compilations. Each time you edit source files, you generate a dynamic page compilation. At some point, the whole application is restarted because the number of loaded assemblies—one for each (re)created page—is too high. The application is recycled also if the physical path of the Web application changes, or any directory under the Web application folder is renamed. Any changes to global.asax, machine.config, or web.config in the application root, or in the Bin directory or any of its subdirectories, and changes occurring in the code-access security policy file, if one exists, are likewise situations that lead to a recycle.

Finally, if you edit the Properties box of the application and modify settings that control the restart/shutdown of the worker process, the application is restarted for the new settings to be applied. These settings are read from machine.config unless you use Windows Server 2003 with the IIS 6.0 process model. If you're taking full advantage of IIS 6.0, an application is restarted if you modify properties in the Application Pools node of the IIS manager. Note also that in addition to all this, in ASP.NET 2.0 an application can be restarted programmatically by calling the method UnloadAppDomain on the HttpRuntime object.

Application restarts are frequent in ASP.NET applications and developers and administrators should pay attention to keep their occurrences under control. When this happens, session state and cached data are lost. This might be a nasty thing for a Web site.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.