CLR rofiler不是分析问题的起点,确切的说,它帮助你鉴别并且隔离有疑问的代码并且追踪内存泄漏。使用CLR Profiler,你可以鉴别哪些代码分配了太多的内存,导致太多次的内存回收已经占有内存时间太长。

    注意:CLR Profiler是一个插入式的分析器,它会严重地减慢被分析的应用程序的运行速度,某些情况下会导致10100倍的速度减缓,该工具不是设计用在产品环境中。


The primary function of CLR Profiler的主要功能是允许你了解你的应用程序如何与托管的,可回收的堆交互的。更重要的是,你可以研究包括:





嗅探的结果被保存在日志文件中,你可以通过CLR Profiler的视图菜单以不同的方式来显示相应的视图。下表描述了几个主要的视图:



Histogram Allocated Types


Gives you a high-level view of what object types are allocated (by allocation size) during the lifetime of your application. This view also shows those objects that are allocated in the large object heap (objects larger than 85 KB).

This view allows you to click parts of the graph so that you can see which methods allocated which objects.

Histogram Relocated Types


Objects By Address


Histogram By Age


Allocation Graph





Assembly, Module, Function, and Class Graph


Heap Graph


Call Graph

Lets you see which methods call which other methods and how frequently.

You can use this graph to get a feel for the cost of library calls and to determine how many calls are made to methods and which methods are called.

Time Line

Displays what the garbage collector does over the lifetime of the application. Use this view to:

-Investigate the behavior of the garbage collector.

-Determine how many garbage collections occur at the three generations (Generation 0, 1, and 2) and how frequently they occur.

-Determine which objects survive garbage collection and are promoted to the next generation.

You can select time points or intervals and right-click to show who allocated memory in the interval.

Call Tree View

Provides a text-based, chronological, hierarchical view of your application's execution. Use this view to:

-See what types are allocated and their size.

-See which assemblies are loaded as result of method calls.

-Analyze the use of finalizers, including the number of finalizers executed.

-Identify methods where Close or Dispose has not been implemented or called, thereby causing a bottleneck.

-Analyze allocations that you were not expecting.