InfoQ Homepage   	  		  			  			                  News                 		  		Java 24 to Reduce Object Header Size and Save Memory

Java 24 to Reduce Object Header Size and Save Memory

submited by
Style Pass
2024-11-19 12:30:04

InfoQ Homepage News Java 24 to Reduce Object Header Size and Save Memory

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.

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:

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.

Leave a Comment