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.

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

  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:

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

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

Comments (4)
  1. weitzhandler says:

    Great! I never knew that exists, I've been eagerly looking for it!!

  2. Christian Haaland says:

    Thanks a lot! A great future feature in visual studio's watches, would be the option "Run until watch changed" or a conditional on the watch.

  3. says:

    Do "Make Object ID" adds a reference to the object? If so will it have any effect in GC?

  4. zainnab says:


    Not in the way you are used to.  The reference it makes never goes out of scope so, unlike a traditional reference, you can view ObjectID information as long as the object is in memory.  It has no impact on collection and doesn't count as a reference for keeping the object in memory.


Comments are closed.

Skip to main content