Visual Managed-Application Profiling

Posted: August 25, 2006 in Codes & Utilities, Programming, Security, Security Testing

Debugging through console watches is powerful where you step in each call and trace the code logic. However As systems evolve and grow more complex with increasing other dependencies (special frameworks, third party tools, environment / OS /patch dependencies) catching memory leaks and usage becomes a nightmare and the ability to peer into their inner workings becomes increasingly valuable.

Say for example you’re working on some component which is to be deployed on a terminal with limited memory and hardisk (POS / Self Service Machines for instance have real limitations in terms of systems resources and RAM). Many developers often overlook these scenarios which causes a problem in the long run.

This article describes some very useful techniques for debugging and profiling .NET based applications. Profiling is a technique used to analyze and determine the exact behavior of your managed applications in realtime (without the source code).

Profiling analyzes:

+ What is going on in the garbage collector heap (Useful for finding heap corruption bugs as well)
+ Method / Object memory allocations.
+ Which methods allocate which types of objects?
+ Which objects survive and time durations.
+ What is on the heap and who is accessing it.
+ What keeps objects alive (useful for determining orphan objects which could have been deallocated to save memory)
+ Call graphs let you see who is calling whom how often.
+ Which methods, classes, modules get pulled in by whom.

The profiler is a good tool to use when you want to find out what’s happening in memory. For instance, ASP.NET developers using InProc sessions state are always curious about how much memory they are using.

Below are some screenshots I took for profiling a sample application.

Application Startup:

Class Graph:

Heap Graph:

Timelines (How much memory is being used at what time)

Application Call Tree:

Resources:

The following sample application profile trace was taken with the CLR Profiler Tool by Microsoft. There are other commercial offerings such as Jetbrains dotTrace and ANTS Profiler with other enhanced functionalities, reporting and automation.

An excellent MSDN article with a sample application using .NET profiling API can be found here:

Blogged with Flock.

About these ads
Comments
  1. munir says:

    This is interesting. Especially graphical timeline viewer looks very cool :-)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s