CLRProfiler是一个可以用于分析.NET程序行为的工具。可用其分析垃圾回收器堆正在发生的事情,例如什么方法分配了什么类型的对象?另外,还提供了调用图(call graph)功能用于显示哪个方法调用了哪个方法。
CLRProfiler可以跟踪分析.NET程序、Services、ASP.NET页面。
CLRProfiler支持命令行方式调用:
CLRProfiler [-o logName][-na][-nc][-np][-p exeName [args]]
The switches have the following meaning:
- –o names the output log file.
- –p names the application to execute.
- –na tells CLRProfiler not to log allocations.
- –nc tells CLRProfiler not to log calls
- –np tells CLRProfiler to start with profiling off (useful when the profiled application turns profiling on for interesting code sections)
CLRProfiler还提供了一个API供程序调用,使用ProfilerOBJ.dll里的函数,可以调用CLRProfiler的很多功能,例如为程序中的某个方法指定跟踪分析,触发堆的快照,输出某些信息到日志文件中去等。
CLRProfiler的缺点是不能附加到已经运行的进程。