PROBLEM
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.
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
private int m_request = 0;
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
Dim m_request = 0
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
Get help from ArcGIS experts
Download the Esri Support App