Make Object ID

Command:  DebuggerContextMenus.AutosWindow.MakeObjectID
Versions:  2008,2010
Published:  3/4/2010
Code:  vstipDebug0015

 

Ever want to track an object even if it is out of scope?  How about see if an object has been garbage collected?  Well, you can do it with the Object ID!  And how do you get one of these amazing things?  Simple, just follow these steps:

 

  1. Set a BreakPoint in your code where you can get to an object variable that is in scope.

  2. Run your code and let it stop at the BreakPoint.

  3. In your Locals or Autos Window, right-click the object variable (note the Value column) and choose "Make Object ID" from the context menu.
     image

  4. You should now see something new in the Value column:
    image

  5. That new value is the Object ID that was generated.  Let's see how it works.

  6. Put the object variable and the new Object ID in your Watch Window:
    image

  7. Now if I go to another method where the object variable (in this case "doc") is out of scope this is the result:
    image

If you want to learn more about Object ID then I suggest you see John Robbin's blog post here:

https://www.wintellect.com/CS/blogs/jrobbins/archive/2008/04/18/finding-an-object-s-gc-generation-in-the-visual-studio-debugger.aspx