Kacper Stachowski
Kacper Stachowski

Reputation: 975

Visual Studio - Count instances of a class created in a runtime

Is there a tool in Visual Studio allowing to check how many instances of a given class was created during debugging (without editing a code)?

Upvotes: 0

Views: 1721

Answers (2)

Pawel
Pawel

Reputation: 1297

Bit late to the party, but this question ranks high in the Google and I found a way to show instances in VS.

Once you hit a breakpoint in the Diagnostic Tools (Ctrl+Alt+F2) select Memory Usage tab. Click Take Snapshot button and when it's done click View Heap. You will see instantiated objects, count, memory usage etc.

Upvotes: 1

Abdullah Nehir
Abdullah Nehir

Reputation: 1047

You can use SOS library on windbg debugging tool. There is a good tutuorial in below link. You can list objects with '!Dumpheap' command

https://netmatze.wordpress.com/2012/08/24/using-windbg-exe-and-sos-dll-to-debug-a-net-4-0-application/

Edit: blog link was lost, I've updated with a good one

Upvotes: 1

Related Questions