Question

I am analyzing a heap dump using a jvisualvm. From the report I can see the classes, number of instances and the size occipied.

What I wanted to know is - the source (which class instantiated) of these objects. For a given object, if I could know all the source classes and the number of instances created by each of those classes, I guess it would be easy to identify the bad candidate.

Is this possible at all? If so, is there any tool better than the other to provide such information?

Was it helpful?

Solution

YourKit provides allocation tracing by size and by number. You can search for particular classes created and find hot spots. The evaluation version is free. ;)

OTHER TIPS

Try:

http://dr-brenschede.de/bheapsampler for an easy to understand summary or http://www.eclipse.org/mat for a more detailed analysis

these tools do exaclty what you're looking for

Did you try

jhat <yourdump>

assuming your creations are of the form:

private Blah blah = new Blah();

For every instance you can see who holds the reference to it. It also provides a powerful query language [OQL]. See for an example: jhat OQL AND in where clause

But if you created it somewhere else and simply passed it on to be held by another class field you won't be able to find it from memory dump [with any tool], as it is only a snapshot.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top