A new initiative within the OpenJDK community, named Project Lilliput, is exploring a proposal to reduce the size of Java’s object header, which could significantly enhance memory usage across Java applications. Spearheaded by Roman Kennke from Red Hat, the project’s primary goal is to shrink the current 128-bit object header down to just 64 bits. The object header in Java’s 64-bit HotSpot VM currently consists of a 64-bit multipurpose header word and a 64-bit class pointer. With most Java objects requiring five to six words of memory on average, this header size has a considerable impact on memory usage.
Reducing the size of the object header would yield several benefits. The most immediate and impactful advantage would be a reduction in overall memory pressure, particularly for applications with large memory footprints, such as in-memory databases. In smaller environments, like containerized applications, this change could significantly decrease both CPU and memory usage. By optimizing memory allocation, Java applications could run more efficiently and with reduced resource overhead, improving performance in both large-scale and small-scale environments.
Project Lilliput’s goals go beyond just reducing the object header size. The project also seeks to make the header layout more flexible, with potential runtime or build-time configuration options that would allow developers to optimize memory usage based on their specific application needs. The proposal also outlines the potential for further reductions in the object header size—down to 32 bits—though this remains a secondary goal. By simplifying and streamlining the memory structure, Java could gain better memory efficiency without sacrificing functionality or performance.
In addition to these benefits, the proposal highlights other specific improvements such as higher object allocation rates, reduced garbage collection activity, and tighter packing of objects. These changes would contribute to a leaner, more efficient runtime environment for Java applications. Overloading the object header with various tracking and state-related data (such as object locking state, garbage collection age tracking, identity hash code, and type information) has long been a challenge, and Project Lilliput promises to address these inefficiencies while preserving essential functionality. If successful, Project Lilliput could result in a significant performance boost for Java workloads of all sizes.