One of the most powerful command available in the SOS.dll is !gcroot. It can help you figure out why an object is stuck in memory and what object(s) is referencing it and keeping it alive. The one problem with !gcroot is that it’s output can be very difficult to navigate through. I remember when I first used this command to try and debug an issue for an application at work, at first I was excited at getting the chance to use this command on a “real world” issue. However, that excitement turned to bewilderment when I saw the output of !gcroot and I just sat there for a few moments whilst I tried to work out what exactly the output was trying to tell me.
Well that was then, and since those days I’ve learned a little bit more about how to read !gcroot’s output. Studying blogs such as this one has helped a lot. Today I was reading John Robbins' blog and I saw a link to this tool, which is an object graph visualizer which runs in VS 2010. The author has created a video to demonstrate this tool and I must say, it looks very interesting! I suggest you check it out.