JAVA: need to calculate object size (Avaialble dump heap)

I have a dump of a HEAP object, accessible to me with me, through Jmap. I also saw a dump through Jhat, but I need to calculate the size of the object. How am i doing this.

In the dump, I see: Example

Class name, summary objects, total size

com.test.app.CallRecord, 2194, 446324

so if I calculated 446324/2194 = 203.So 203 bytes is the size of 1 CallRecord object. This is true? I have a confusion here. What is this size. Does it also include link size?

m Confused ..... Someone asked me to tell him the size of the CallRecord object. Should I tell him 203 bytes. I have doubts whether it is right or not.

Does 203 bytes include the size of the link under the CallRecord object.

How to calculate. Your thoughts are requested.

Thanks in advance.

+4
source share
2 answers

It depends on the total size of the shalow or saved .

  • Shallow size

    The shallow size of an object is the amount of memory used to store the object itself. Referenced objects are not counted.

  • Saved size

    The stored size of an object is the amount of memory that can be freed when the object is collected by the garbage collector.

+2
source

I would recommend using some kind of memory analysis tool (profiler). YourKit is great for this, but quite expensive, the Eclipse MAT is good too, and it's free. VisualVM is pretty simple, but it's good enough and free ... (I often used them all often because they have everything that others lack.)

+2
source

Source: https://habr.com/ru/post/1432682/


All Articles