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?
Asked
Active
Viewed 270 times
1
-
No, unfortunatelly I need more detailed answer. Maybe wheb I have a time I'll try to analyze source code myself and write an answer to this question – Sergey Ponomarev Aug 26 '18 at 17:50
2 Answers
1
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...

Eugene
- 117,005
- 15
- 201
- 306
-
Yes, J9 has compressed references, and it also aligns objects to 8 bytes. – Doradus Jun 17 '23 at 13:24
1
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.:
> !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

Peter Bain
- 46
- 1
-
a must read here would be Aleksey Shipilev - what head dumps are lying about – Eugene Feb 04 '19 at 02:34