OpendJDK has a Java Object Layout (JOL) tool which allows to estimate instance real memory size of specified object. It can show an object layout for HotSpot but will it be the same in OpenJ9?
OpenJ9 VM Object Layout
300 views Asked by Sergey Ponomarev At
2
There are 2 answers
1
On
Well, IMHO, the answer is no, for at least the fact that if you count references sizes too, there is UseCompressedOops
that is HotSpot specific. May be J9 has it too, but may be not.
There is the issue of padding too, in HotSpot objects are 8 bytes
aligned (there are more complicated things about inheritance), but I don't know if J9
does that...
If you have a system core (e.g. via -Xdump:system:events=vmstop) you can look at the sizes of live objects, including the padding and alignment using jdmpview's
!objectsizeinfo
command, e.g.: