Mr. Boy
Mr. Boy

Reputation: 63720

Find all instances of a class while debugging in Eclipse

I was wondering if the way Java/JVM works means debugging tools like Eclipse can show me a list of all instances of a given class? I suppose one could write some reflection code but I don't want to break execution at the same place every time... rather I;d like to break execution and bring up a list of all MyClass123 objects in a debug window.

Is this even possible? Is it provided in Eclipse or any plugin?

Upvotes: 8

Views: 6261

Answers (2)

Tobias
Tobias

Reputation: 4074

Yes, it's possible in the standard eclipse debugger. See here. While debugging, right-click on a variable entry in the 'Variables View' and then click on 'All Instances':

enter image description here

This will open a list like this:

enter image description here

Upvotes: 8

Yogendra Singh
Yogendra Singh

Reputation: 34367

You may want to instatall Eclipse Test & Performance Tools Platform plugin in your application and perform MemoryAnalysis. This gives you details around all different objects in memory and their references.

You will not need to put any breakpoint in the code. It will gather the required data on its own.

Upvotes: 2

Related Questions