Home United States USA — software Java 24 to Reduce Object Header Size and Save Memory

Java 24 to Reduce Object Header Size and Save Memory

66
0
SHARE

JEP 450 (Compact Object Headers) has been targeted for delivery in JDK 24. This currently experimental feature optimizes heap utilization by shrinking the size of the mandatory object header in HotSpot. This should reduce overall heap size, improve density of deployments, and increase data locality.
JEP 450 (Compact Object Headers) has been targeted for delivery in JDK 24, and has already been merged to main.
This currently experimental feature optimizes heap utilization by shrinking the size of the mandatory object header in HotSpot. This should reduce overall heap size, improve density of deployments, and increase data locality.Overview of current implementation
HotSpot stores all objects in the Java heap, a contiguous area of the « C heap » of the process. Objects in Java are always handled by reference and so, for example:
The target address of a Java reference is always the start of an object header (which is mandatory in current versions of HotSpot).
The header is present on every object (and arrays have an additional 32 bits of header to store the array’s length). The mark word is the first 64 bits and is used for instance-specific metadata, i.e. supporting features like:
Garbage Collection – Storing an object’s age (& possibly forwarding pointers)
Hash codes – Storing an object’s stable identity hash code
Locks – Storing an object’s lock / monitor
Under some circumstances, the mark word will be overwritten and replaced by a pointer that refers to a more complex data structure. This slightly complicates the implementation of compact object headers.
After the mark word follows the class (or klass) word, which is used to calculate a pointer to metadata shared by every object of this class type.

Continue reading...