views:

36

answers:

1

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 mean, 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.

A: 

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

Ivan