csharp性能调试

记录 csharp 的性能调试. #todo/笔记

所有的 dotnet 全局工具在这里 .NET Diagnostic tools overview - .NET | Microsoft Learn

dotnet-monitor

1
dotnet-counters.exe ps
1
2
# 每秒刷新1次进程22884的情况
dotnet-counters monitor --refresh-interval 1 -p 22884
1
dotnet-dump collect -p 4807
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dotnet-dump analyze core_20190430_185145

# 输入 SOS 命令
# 分析对象大小与占用
dumpheap -stat

# 查看指定对象的情况  方法表 (MT)
dumpheap -mt 00007faddaa50f90

# 查看此资源大多被什么对象所持有,由此定位问题
gcroot -all 00007f6ad09421f8
1
2
3
4
dotnet-trace collect -p pid
# 等待一段时间后enter或ctrl+c关闭
# 抓到本地以后用perfview打开分析
https://github.com/microsoft/perfview