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?
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 (eg via -Xdump:system:events=vmstop) you can look at the sizes of live objects, including the padding and alignment using jdmpview's !objectsizeinfo
command, eg:
> !objectsizeinfo java/lang/String
Object field size summary
=========================
Class Total size Data size Space used Instances char byte short int long float double boolean object hidden
---------------- ---------- --------- ---------- --------- ---- ---- ----- --- ---- ----- ------ ------- ------ ------
java/lang/String 16 10* 66752 4172 0 2 0 0 0 0 0 0 1 0
Class Total size Data size Space used Instances char byte short int long float double boolean object hidden
Heap summary 66752 41720 66752 4172 0 8344 0 0 0 0 0 0 4172 0
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.