views:

1199

answers:

4

I would like to use something like CLR Profiles on .Net 2.0 to see what objects are taking more space in the heap at any given time (of an ASP.Net worker process).

However, the CLR Profiler only lets me START an app, not attach to an existing one. I assume this is because it tracks allocations and GC too, but i'm not very interested in that. I would just like something that takes a snapshot of the current state of the heap, and shows me what is there and how many objects of each kind there are, and how many bytes total are being used by each object type.

Any ideas?

A: 

Have you looked at RedGates .NET Profiler?

Its been a while since I used it, but I'm faily sure you can attach to any CLR process at anytime.

FlySwat
+3  A: 

.Net Memory Profiler is exactly what you need. It's not free but there's a trial version. Actually I used the trial to find leaks on our last project. One notable feature is:

Easily identify memory leaks by collecting and comparing snapshots of .NET memory

I think this is what your looking for.

John
+5  A: 
  • Attach a debugger

cdb -p

  • load .net debugger extensions

.loadby sos mscorwks

  • dump the heap in a format the CLRProfiler understands

!TraverseHeap heap.txt

  • detach debugger

qd

  • load heap.txt in the clrprofiler app
Peli
A: 

This article from MSDN talks about how to use the free CLR Profiler to compare to instances of the stack. You're right that you can't currently attach CLR Profiler to a running process (the article explains why), but, for what it's worth, it sounds like you will be able to soon.

Doug Mulley