Visualizing Runtime Object Graphs

by clovett15. January 2010 16:28

One of the first questions people seem to ask when they see the Dependency Graph features of Visual Studio 2010 is whether it can also be used to visualized runtime object graphs.

In this Video (WMV, or MP4) I will show you how that can be done using the SOS debugger extensions and specifically the GCRoot command.  I've used this technique several times to help figure out some really complex memory leak bugs and so I'm confident you will find this to be a useful tool to add to your toolbox of tricks.

The code for the GCRootToDGML tool is available to download so you can try this out yourself, it should work with any recent version of Visual Studio 2010.

Adding links some excellent work done by others on this subject below:

Tags:

Comments (67) -

Pavan.
Pavan.
8/25/2009 7:08:02 AM #

Great post! Is ther a way to automate the "dump gcroot output to .log file and then manually run your program". Is there a way to spawn it from the immediate window itself?

Thanks,
Pavan.

Chris Lovett
Chris Lovett
8/26/2009 9:15:51 PM #

I don't know the answer to your questions, but you are right, this is exactly the next step. Let me know if you find a solution Smile

Aaron Marten
Aaron Marten
8/31/2009 7:41:08 AM #

Nice!

Jandeep
Jandeep
9/3/2009 5:24:32 PM #

Awesome post ! link to the Video is broken ..can you fix it?
thanks

Chris
Chris
9/4/2009 4:59:39 PM #

I added mp4 videos (slightly smaller) with links to screencast.com which should help.

Gregory Babski
Gregory Babski
10/24/2009 3:00:14 AM #

Nice work! I noticed in your video you felt forced to use !dumpheap to get the address of your player instance. You should be able to get it directly at the breakpoint you set with (in the immediate window):
&player
Which returns
0x0040ef2c
    player: 0x02669088
The nested address being the one of interest.

This works in VS2008 - not sure if it still does in VS 2010.

Martin Connell
Martin Connell
10/31/2009 4:24:52 PM #

Thanks for the interesting video and the DGML visualizer looks quite sexy; but isn't your advice to watch out for object reference cycles kind of ironic given .NET/CLR was originally pushed as a solution to such woes?

Indeed, it might even bring a wry smile to the face of anyone who has stuck with C++ and stubbornly resisted the lure of neglecting the object reference graph at the design stage.

Robert
Robert
1/2/2010 9:00:12 AM #

Thanks for the video. I've been wanting to implement a object reference graph, but had a few questions on some issues I was seeing. You covered it all in the video. Thanks again.

James
James
1/9/2010 10:03:56 AM #

Just wanted to say thank you for the video on visual studio 2010, i've never used the sos debugger plugin before and it came in handy. Cheers!

Andre Gemmen
Andre Gemmen
1/31/2010 10:38:22 PM #

Great stuff my friend!  Visualizing Runtime Object Graphs was a wonderful read. Love reading stuff about this.

Calpe Villas
Calpe Villas
2/11/2010 10:42:42 AM #

nice post.. I especially like the code to GCROOTtoDGML tool

Julio Rapko
Julio Rapko
3/27/2010 8:54:45 PM #

"Simplicity is not the opposite of complexity. Simplicity is too often an excuse for being simplistic. The world doesn't need any more stupid software. The opposite of complexity is beautiful, elegant design."

I agree, for I have noticed that some software, especially computer games, are beautifully stable, while others crash like there is no tomorrow.

Aurea Gillen
Aurea Gillen
3/29/2010 3:18:08 AM #

great job on the videos. i really enjoyed watching them. keep up the good work...

car hire france airport
car hire france airport
4/6/2010 2:52:30 AM #

great job on the videos. i really enjoyed watching them.keep going buddy.........

Mark
Mark
4/9/2010 1:09:53 AM #

The Videos are great. Thx for this useful tip with the sos debugger.

ciao from germany

Money Origami
Money Origami
4/23/2010 3:42:28 PM #

Great post by videos. I especially like the videos. I especially like the code to GCROOTtoDGML tool

projector lights
projector lights
4/23/2010 5:10:26 PM #

Nice post i just wants to offer my thaks for the video on visual studio 2010 . Infact i love to know more about this.

Ultimate WOW Guide Review
Ultimate WOW Guide Review
4/24/2010 4:27:28 PM #

Cheers for the awesome video, the visualizer, and the code to GCROOTtoDGML tool is tidy. I've been searching for an object reference graph. You've covered everything I think. Cool.

Florida Phone Systems
Florida Phone Systems
4/27/2010 2:35:50 PM #

The visualized runtime object graphs are a great time saver when using the Dependency Graph features of Visual Studio 2010.  However, they are definitely difficult to use, and I appreciate the guide.

Money Origami
Money Origami
5/11/2010 3:36:51 AM #

It great to know about visualized runtime object graphs as they are great time saver when using the Dependency Graph features of Visual Studio 2010. Thanks for great information about Visual Studio 2010.

Greener Life
Greener Life
5/11/2010 5:29:09 PM #

Thanks for nice tutorial!

house extension costs
house extension costs
5/12/2010 7:51:47 AM #

I love visualising runtime graphs now after your article, cheers.

Father's Day Gift Ideas
Father's Day Gift Ideas
5/12/2010 7:51:49 AM #

Excellent! Ive now added GCRootToDGML to my tool collection. Thanks for upping the link location.

Enclosed cargo trailer
Enclosed cargo trailer
5/12/2010 2:43:41 PM #

Great post! Is there a way to automate the production program. Is there a way to spawn the immediate window itself?

Low Cost Auto Insurance
Low Cost Auto Insurance
5/13/2010 6:28:35 AM #

Thanks for the video. I've been wanting to implement a object reference graph and you made it so simple to understand.  just wanted to let you know your help is really appreciated.

Soccer
Soccer
5/18/2010 5:32:50 AM #

Thanks for posting your video.  

It is so much easier to understand by watching rather than reading.

what is neuropathy
what is neuropathy
5/19/2010 4:59:28 AM #

This was really very helpful information. I really appreciate everything.

Boat trailer wheels
Boat trailer wheels
5/19/2010 12:36:39 PM #

Thanks for the interesting video and the DGML visualizer looks quite good.

roger t
roger t
5/20/2010 3:23:28 PM #

Thanks for the interesting video. Learning to use GCRootToDGML hasn't been easy!

Opony
Opony
5/21/2010 6:29:03 PM #

Thanks for good article. Hope to see more soon.

saint paul computer repair
saint paul computer repair
5/22/2010 8:39:53 AM #

Great video!  It really helped me a lot.

Web Design Inspiration
Web Design Inspiration
5/23/2010 1:56:20 AM #

Awesome post, can I link to this from my website?

puppy potty training
puppy potty training
5/23/2010 4:18:36 PM #

Extremely amazing post. The author has given a perfectly explain how to visualize Runtime object graph. Thank you for sharing this update. We will be waiting for more exciting post.

QQ
QQ
5/25/2010 5:44:15 AM #

now added GCRootToDGML to my tool collection. Thanks for upping the link

Universal Studios Tickets
Universal Studios Tickets
5/28/2010 2:33:06 PM #

Thanks, now off to play with the SOS debugger..

Rosh
Rosh
5/28/2010 3:50:13 PM #

This is really great info. Thank you for sharing it with us!

Schildersbedrijf Rotterdam
Schildersbedrijf Rotterdam
5/28/2010 9:44:09 PM #

I didn't think about visualizing this. It sure looks like a great tool to help track down bugs!

Roger Gordon
Roger Gordon
5/30/2010 6:29:53 AM #

Thanks for posting your video. the information is very useful.

Edwin
Edwin
6/1/2010 6:32:17 PM #

Thanks I was looking into GCRoot and your video helped me a bit more on my way

ice vending man
ice vending man
6/12/2010 4:56:32 AM #

Is ther a way to automate the "dump gcroot output to .log file

dog boy john
dog boy john
6/26/2010 8:46:18 PM #

Just wanna say thanks for the heads up, helpful vid on GCRootToDGML tool.

vending machines
vending machines
6/30/2010 10:30:26 AM #

I wish that it were still so easy; fixing bugs that related to memory leaks and user-related issues.  Lately, I've been coming across loads of injections and the like.  I can't imagine why people want to destroy things.  I feel like I'll be eating from a vending machine my whole life because I don't have time anymore to eat let alone figure out what the latest is on the "seek and destroy perfectly good websites" front.

Vending machines
Vending machines
6/30/2010 12:03:58 PM #

I love that you posted this video!  I did it myself with the code that you provided just to say I did it. I'm digging where graphics are going these days!!!

Jim Stegen
Jim Stegen
8/9/2010 8:33:14 AM #

Excellent post.  I'll give that gcroot tool a try.

Tony
Tony
8/10/2010 2:01:54 AM #

Thanks for the video. I've been wanting to implement a object reference graph and you made it so simple to understand.  just wanted to let you know your help is really appreciated.

EMR transcription company
EMR transcription company
8/18/2010 5:09:45 AM #

Hi Clovett.. you're provided video is a very huge help, it gives a solutions specially the link of the Tool which I downloaded and Yes, it works on Visual Studio 2010. You did a great job! this post will also help to other people seeking for this extension.

Once again, thank you.

theory test
theory test
9/14/2010 11:10:49 PM #

Great video, first time i've seen this being used, will have to give a go. added +rating

AutoBlog Samurai Review
AutoBlog Samurai Review
10/14/2010 5:51:14 AM #

Excellent work on videos mate. Loved It

crystal
crystal
10/22/2010 10:15:52 PM #

Thanks for the awesome post.

moving London
moving London
11/12/2010 11:38:00 AM #

Thanks .... really needed the GCRootToDGML tool, came in handy with other stuff ....and liked the video too

Tom Andrews
Tom Andrews
11/26/2010 8:22:45 AM #

Videos are great.. worked perfectly.. thanks!!!

Kate Smith
Kate Smith
11/26/2010 8:27:05 AM #

Really helpful videos.. thanks

NewGadgetBlog
NewGadgetBlog
11/27/2010 9:14:58 AM #

Hi there. Thank you for the tutorial. Unfortunately I am having a problem with the code for the GCRootToDGML tool . The link appears to be dead. Maybe someone can post another link,please?

Thank you

Car Games
Car Games
11/30/2010 8:14:02 AM #

I have tested GCRootToDGML tool in Visual studio and worked like a charm...Thanks for this useful tool !

Gaini de rasa
Gaini de rasa
12/3/2010 6:26:00 AM #

I like this.Dependency Graph features of Visual Studio 2010.  However, they are definitely difficult to use, and I appreciate the guide.

Brett Mont
Brett Mont
12/6/2010 3:10:45 PM #

Very helpful videos... please keep them coming.

marketing push
marketing push
12/11/2010 10:52:07 AM #

you're provided video is a very huge help, it gives a solutions specially the link of the Tool which I downloaded and Yes, it works on Visual Studio 2010.

ile de ré
ile de ré
12/12/2010 2:19:37 AM #

GCRootToDGML is an excellent tool, nice vid!!

UAE offshore company
UAE offshore company
12/13/2010 2:23:54 AM #

Thank you very much for the videos on visual studio 2010! They were really very helpful.

Mike
Mike
12/13/2010 2:40:14 AM #

Thanks a lot! The GCRootToDGML tool is absolutely what I needed! And the video was also great!

model search 2011
model search 2011
12/28/2010 10:31:32 PM #

Hey man great video this will definitely come in handy.  Also, thanks for the link to the  GCRootToDGML tool itself...I'm definitely going to be trying this out.

Lake Erie Fishing
Lake Erie Fishing
12/29/2010 8:52:32 PM #

Been trying to get a grasp of Visual Studio 2010 for the last month. resources such as your own have proved to be an immense help along the way

Harry
Harry
12/31/2010 9:17:47 AM #

I've been wanting to implement a object reference graph and you made it so simple to understand.  just wanted to let you know your help is really appreciated.

flecx
flecx
1/3/2011 11:53:45 AM #

Short yet concise, I had never used SOSdebugger before hopefully it will shave a few hours off a couple of problematic projects!

sem
sem
1/6/2011 8:35:56 AM #

Yeah, Mohamed El-Geish extension works great. Indeed graphs can easily interact with Visual Studio 2010. Thanks for the post& link.

Janile Evans
Janile Evans
1/6/2011 9:07:12 PM #

I haven't used much my studio visual tool and I'm yet to actually grasp its usage properly. In your video you have shown me helpful ideas on it. I haven't tried using the SOSdeblugger before and hopefully it can help fix some of my problems. Also many thanks for the GCRootToDGML tool download. Hopefully it can help me as well.

Sarah
Sarah
1/12/2011 7:59:14 AM #

This is great and I appreciate this. Thanks a lot!

About the author

Chris Lovett is a Software Engineer at Microsoft working on Windows Phone.

See Resume in SVG

Month List