VisualVM: how to find the size of an object on the heap, including all the objects it refers to in its fields?

How do I find the size of an object on the heap, including all the objects it references from its fields?

In the Classes view, under the heap dump, size indicates only the "small" size of the object. I would like to know in transit what the size of an object is, basically the total size of the objects that it references through the fields.

thank

+5


source to share


2 answers


Go to Instance and click Calculate Remaining Dimensions.



+7


source


You can get saved and small size. See the differences there https://www.yourkit.com/docs/java/help/sizes.jsp
*) To get the "Saved size" jvisulVM-> "monitor" tab-> "heap dump" tab-> go to the generated heapdump -> click on it "OQL Console" โ†’ and below, for example, "Query Editor", write your OQL sql, for example, to find a string with the value "GHT", the query will be select s from java.lang.String s where s.toString().equals("GHT")

โ†’ click "execute" โ†’ and as a result of the query, click on the required reference->, you will see information about your instance there and you can click Calculate Remaining Size to get what you want.
*) To get "small" size jvisulVM-> "monitor" tab-> "heap dump" tab-> go to the created heapdump-> click on it "OQL Console" -> and at the bottom of this "Query Editor" write your SQL- OQL code, for example, to find a string with the value "GHT", the request will be select sizeof(s) from java.lang.String s where s.toString().equals("GHT")

โ†’ click "execute" -> you will see the size of your object in bytes
. You can read more about it here "Small" https://blogs.oracle.com / sundararajan / querying-java-heap-with-oql



0


source







All Articles