Problem: The ASP.NET worker process progressively increases memory usage


When the Web server is experiencing extreme usage conditions for prolonged periods of time and the ASP.NET application uses the ArcGIS Server ADF for .NET, the ASP.NET worker process begins to increase its usage of memory and in some cases restarts.


The Microsoft .Net Framework garbage collector is not initialized under these extreme conditions to clear the ASP.NET worker process memory.

Solution or Workaround

The solution is to invoke the Garbage Collector explicitly within the application and wait for pending finalizers. This is a heavy process, so it is recommended to only induce the garbage collector after every 'n' requests.

The following code demonstrates how achieve this for C# and VB.NET. Experiment with the interval to achieve the maximum performance for the application.

C# Applications
For C# applications, open and edit Global.asax.cs

  1. Add m_request variable inside Global class:
private int m_request = 0;
  1. Edit Application_EndRequest function:
protected void Application_EndRequest(Object sender, EventArgs e)
		if (m_request % 10 == 0)

VB.Net Applications
For VB.Net applications, open and edit Global.asax.vb

  1. Add m_request variable inside Global class:
Dim m_request = 0
  1. Add Application_EndRequest function:
Sub Application_EndRequest(ByVal sender As Object, ByVal e As EventArgs)
                	If m_request Mod 10 = 0 Then
        	      	End If
        	 	m_request = m_request + 1
End Sub