Hotspot memory layout objects

 

Object header

class oopDesc {
 ...
private:
  volatile markOop _mark;
  union _metadata {
    Klass*      _klass;
    narrowKlass _compressed_klass;
  } _metadata;
  ...
}

In the object pointer called hotspot oop (ordinary object pointer), and the structure of the object is oopDesc head .. In addition to Klass (The reason why is because the class is called klass C ++ keywords) outside pointer ,, ,, field also made a _mark is because in addition to the class information object, and some objects need to retain information, such as age, GC, lock status Wait.
_klass is present in the union of the type of _metadata, union types were allocated by the largest member of that, then this memory depends on the interpretation of the code which is used in the field.

typedef juint  narrowKlass; // typedef uint32_t juint;

typedef class markOopDesc* markOop;

Default accounting object header 16 bytes, the compressed object pointer in the open (through -XX: + UseCompressedClassPointers), accounting for 12 bytes, is enabled by default. 

 

Object members

  • long / double - 8 bytes
  • int / float - 4 bytes
  • short / char - 2 bytes
  • byte/boolean - 1 bytes
  • reference type - 4 or 8 bytes

When the heap is less than 32G, compression enabled by default pointer .. The corresponding control parameters for the JVM: -XX: +/- UseCompressedOops.

 

Command associated with the object memory layout is as follows:

(1)-XX:+UseCompressedClassPointers。

(2)-XX:+/-UseCompressedOops。

(3) -XX: PrintFieldLayout can view an object's memory layout.

(4) -XX: FieldsAllocationStyle = mode, the default mode is 1.

(5) -XX: +/- CompactFields since when filling the cavity gap would be formed, for example using compression kclass indicators in the first 12 bytes of account, if it is long, then later, long 8-byte alignment requirements, there will be four intermediate byte cavity, in order to efficiently use, can be relatively small objects int / short / byte into the other to, at the same time provides a switching control of the JVM characteristic -XX: +/- CompactFields, enabled by default.

 

 

Guess you like

Origin www.cnblogs.com/mazhimazhi/p/11333977.html
Recommended