ANTS Profiler

Latest version: 4.3

ANTS Profiler

Knowledge Base

Abnormal termination caused by .NET 2.0 critical finalizer threads

Category: Troubleshooting & error messages
Date: 19 Nov 2008
Product: ANTS Profiler
Versions: 2,3

When profiling a .NET Framework 2.0 or 3.0-based application, the following error may be encountered in ANTS Profiler when the application is closed:.

"The application you're profiling has exited without shutting down normally. Profiling will now stop."

The .NET Framework version 2.0 had implemented a 'Critical Finalizer' to free up stubborn resources in applications. This starts a new thread at the time of application termination to attempt to clean up objects that have pending finalizers that are deadlocked, mainly on internal and unmanaged resources. This situation seems to occur mainly when profiling Windows Presentation Foundation applications.

When the critical finalizer runs, it attempts to free all locks and handles on objects in the process. Unfortunately this also means the ANTS Profiler named pipe, which sends the profiling results from the core to the UI. When the critical finalizer closes the pipe, ANTS Profiler reports:

"The application you're profiling has exited without shutting down normally. Profiling will now stop." No results are sent to the UI. If a log has been running during the profiling session (a LOGS folder can be created in the ANTS Profiler 3 installation folder) then the following information can be seen:

28/11/2007 10:06:03 TRANSFER - Unknown event ID from core: 0
28/11/2007 10:06:03 TRANSFER - Listening for event from core
28/11/2007 10:06:03 TRANSFER - Closing PipeHandler Event Listener due to Win32 error: 109
28/11/2007 10:06:03 TRANSFER - PipeHandler reported: PipeClosedWhenReading

Taking a performance profiling snapshot before the program crashes will reveal a new thread that contains a few GC and finalizer methods.

This situation does not currently have a workaround, but ANTS Profiler can still be used to collect performance and memory profiling data by taking snapshots rather than relying on the results to be displayed automatically when the program is closed. If the above error message is displayed because of a critical finalizer thread closing the ANTS Profiler named pipe, there is about a 30-second gap in the time the program is terminated and the critical finalizer closes the ANTS Profiler pipe: this window can be used to take a final snapshot manually by clicking the 'Take Snapshot' button in the user interface. It would also be possible to leverage the Profiler's API to take the final performance snapshot, if the ANTS Profiler licence is for the 'Professional Edition'.

Document ID: KB200711000199 Keywords: ANTS,Profiler,WPF,application,finalizer,shutting,normally,

Was this article helpful?

Search support
Forums
Visit the ANTS Profiler forum.

ANTS Profiler

all products