botenvouwer
botenvouwer

Reputation: 4432

Is there a way in Visual Studio to see the actual objects in memory

I would like to see the objects created by my program. I searched on google and stack and I looked around in visual studio but I can't find anything about this.

I'm not looking for memory usage analyzer view. I just want to see all created objects and their values.

Is there a way to see all live objects in Visual Studio 2015?

Upvotes: 11

Views: 13328

Answers (1)

Paweł Łukasik
Paweł Łukasik

Reputation: 4163

You can see the memory of the object by using Memory window in VS.

Just go to Debug->Windows->Memory and open one of the four available or use the shortcut Ctrl+Alt+M, 1-4. Then while debugging the application just type the name of the variable in the address field to translate it to a memory location and show the memory.

Assuming you code is like this:

var memObject = new MemObject {IntField = 42, StringField = "String"};
var str = "My string";

and you have a breakpoint after the second line. When you type str into and address field you will be moved to the memory location of this object

enter image description here

the same goes with writing memObject there.

If you want to see all the objects I think the only way is to us sos in WinDbg.

Upvotes: 7

Related Questions