ANTS Performance Profiler

Latest version: 7.4

ANTS Performance Profiler

Knowledge Base

ASP .NET 1.x application recycling causing incomplete results

Category: Troubleshooting & error messages
Date: 17 Jun 2009
Product: ANTS Performance Profiler
Versions: 4.0
Platforms: ASP .NET 1.x, IIS 5,6,7, Development Web Server

When profiling an ASP .NET web application, either hosted in IIS or in the development web server, only results for the first web page may be shown by ANTS Profiler.

The cause of this may be that the ASP .NET worker process (ASPNET_WP.EXE) may be recycling whereas it would not normally when ANTS Profiler is not attached to it, possibly because of the additional memory pressure introduced or slower performance.

In order to figure out why the application is recycling, it is possible to trap and log any application shutdowns to the event log. To do this, use Notepad to open the web application's Global.aspx file. In some cases, the necessary code change needs to be made in Global.asax.cs or Global.asax.vb, which is located in the folder of the web application. Inside the Application_End() method, add the following code:
/ [C#] /
////////////////////////////////////////////////////////////////////////////////////////////////////////////
 HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime",
                                                                                            BindingFlags.NonPublic
                                                                                            | BindingFlags.Static
                                                                                            | BindingFlags.GetField,
                                                                                            null,
                                                                                            null,
                                                                                            null);

            if (runtime == null)
                return;

            string shutDownMessage = (string)runtime.GetType().InvokeMember("_shutDownMessage",
                                                                             BindingFlags.NonPublic
                                                                             | BindingFlags.Instance
                                                                             | BindingFlags.GetField,
                                                                             null,
                                                                             runtime,
                                                                             null);
            string shutDownStack = (string)runtime.GetType().InvokeMember("_shutDownStack",
                                                                           BindingFlags.NonPublic
                                                                           | BindingFlags.Instance
                                                                           | BindingFlags.GetField,
                                                                           null,
                                                                           runtime,
                                                                           null);
            if (!EventLog.SourceExists(".NET Runtime"))
            {
                EventLog.CreateEventSource(".NET Runtime", "Application");
            }
            EventLog log = new EventLog();
            log.Source = ".NET Runtime";
            log.WriteEntry(String.Format("\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}",
                                         shutDownMessage,
                                         shutDownStack),
                                         EventLogEntryType.Error);

//////////////////////////////////////////////////////////////////////////////////////////

Note that you may also need to add the following "using" statements to the top of the code file:

using System.Diagnostics;
using System.Reflection;

Once this has been done, ASP .NET will log the reason for the application unload to the application event log. This may be useful information for our support department to advise you on a fix for the problem.

Document ID: KB200809000301 Keywords: ANTS,Profiler,ASP,.net,missing,pages

Was this article helpful?

Search support
Forums

ANTS Performance Profiler

all products