Drahcir
Drahcir

Reputation: 11972

How can I find out what is preventing garbage collection of an object?

Some of my objects are not being garbage collected, I need to find out where the references to the object are and what is preventing the garbage collection.

I'm using Visual Studio Express.

Upvotes: 4

Views: 1758

Answers (3)

Ian
Ian

Reputation: 34489

You could try using Ants Memory Profiler which is a very popular tool. It's fairly easy to use and it attempts to give you a graph illustrating what is holding on to your references. Underneath I believe it does something similar to that which Bond suggested, but it gives a much simpler user experience.

It comes with a free 14 day trial. An example of the instance graph is shown below:

enter image description here

Upvotes: 3

vanos
vanos

Reputation: 109

I would suggest:

  1. Analyze your code and debug
  2. If you are unable to find the leaking you could try this tool: Memprofiler

Upvotes: -1

Ventsyslav Raikov
Ventsyslav Raikov

Reputation: 7192

you can try the sos extensions for windbg particularly the dumpheap and heapstat commands

Upvotes: 3

Related Questions