OpenJ9 VM Object Layout

300 views Asked by At

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?

2

There are 2 answers

1
Peter Bain On

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       
1
Eugene 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...