views:

45

answers:

2

Hi, is it possible to list all objects stored in heap. I would like to do something like this:

IEnumerable<GCHandle> listOfObjectsInHeap = GetListOfObjectsFromHeap();
A: 

I am not aware of any managed function that allows you to do this. You could retrieve this information using the HeapWalk function. Here's an example of using it (it creates a new heap but you could retrieve the current process heap with GetProcessHeap).

Darin Dimitrov
+1  A: 

You can use the Profiling API to achieve this. Unfortunately not in managed code.

Julien Lebosquain