Package org.github.jamm
Interface MemoryLayoutSpecification
public interface MemoryLayoutSpecification
Information about the memory layout used by the JVM running the code.
This code assume that the JVM is an HotSpot JVM.
The memory layout for normal Java objects start with an object header which consists of mark and class words plus possible alignment paddings. After the object header, there may be zero or more references to instance fields.
For arrays, the header contains a 4-byte array length in addition to the mark and class word. Array headers might also contain some padding as array base is aligned ( https://bugs.openjdk.org/browse/JDK-8139457),.
Objects are aligned: they always start at some multiple of the alignment.
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the size of the array header.int
Returns the number of bytes used to pad the fields/classes annotated withContended
.static MemoryLayoutSpecification
int
Returns the object alignment (padding) in bytes.int
Returns the size of the object header (mark word + class word).int
Returns the size of the reference to java objects (also called oops for ordinary object pointers)
-
Method Details
-
getArrayHeaderSize
int getArrayHeaderSize()Returns the size of the array header.The array header is composed of the object header + the array length. Its size in bytes is equal to
getObjectHeaderSize()
+ 4- Returns:
- the size of the array header.
-
getObjectHeaderSize
int getObjectHeaderSize()Returns the size of the object header (mark word + class word).- Returns:
- the size of the object header
-
getObjectAlignment
int getObjectAlignment()Returns the object alignment (padding) in bytes.The alignment is always a power of 2.
- Returns:
- the object alignment in bytes.
-
getReferenceSize
int getReferenceSize()Returns the size of the reference to java objects (also called oops for ordinary object pointers)- Returns:
- the java object reference size
-
getContendedPaddingWidth
int getContendedPaddingWidth()Returns the number of bytes used to pad the fields/classes annotated withContended
.- Returns:
- the number of bytes used to pad the fields/classes annotated with
Contended
.
-
getEffectiveMemoryLayoutSpecification
-