开发者

.NET allocations profiling

开发者 https://www.devze.com 2022-12-28 10:07 出处:网络
I need a way to track all allocations in a .NET application that happen during a single step in the process of debugging my application. I me开发者_开发知识库an, when I\'m in the debugger, stepping th

I need a way to track all allocations in a .NET application that happen during a single step in the process of debugging my application. I me开发者_开发知识库an, when I'm in the debugger, stepping through code, I would like to see for a single step what allocation took place. Is there a tool or a way to do it? I tried several memory profilers including CLR profiler, JetBrains and .NET Memory Profiler 3.5 and none of them seems to provide this kind of funcionality.


You could use WinDBG with something like this

.load C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\SOS.dll
.logopen log.txt
bp mscorwks!FastAllocateObject "!DumpMT poi(@esp+4); g"
bp mscorwks!AllocateObject "!DumpMT poi(@esp+4); g"

This should break on all AllocateObject/FastAllocateObject and dump MethodTable passed to these functions in log.txt .. It will probably get very slow as number of allocated objects increase

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号