PROBLEM

The ASP.NET worker process progressively increases memory usage

Last Published: April 25, 2020

Description

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.

Cause

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)
		{
			GC.Collect();
			GC.WaitForPendingFinalizers();
		}
		m_request++;
		}

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
            		GC.Collect()
            		GC.WaitForPendingFinalizers()
        	      	End If
        	 	m_request = m_request + 1
End Sub

Article ID:000006944

Software:
  • ArcGIS Server

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic