JDK-8361187 : Compact Object Headers by Default
  • Type: JEP
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Draft
  • Resolution: Unresolved
  • Submitted: 2025-07-01
  • Updated: 2025-08-24
Related Reports
Relates :  
Relates :  
Sub Tasks
JDK-8360700 :  
Description
Summary
-------

Make compact object headers the default object header layout, and deprecate the old 12-byte object header layout, with the intention to remove the old layout in a future release.


Non-Goals
---------

It is not a goal to completely remove/obsolete the old 12-byte object header layout at this time.


Motivation
----------

Compact object headers were introduced as an alternative object-header layout by [JEP 450](https://openjdk.org/jeps/450) in JDK 24, and turned into a full product feature by [JEP 519](https://openjdk.org/jeps/519) in JDK 25. Features of this size are best introduced carefully and gradually, so we have not turned it on by default, yet.

Since JDK 24, compact object headers have proven their stability and performance.

They have been tested at Oracle by running the full JDK test suite. They have also been tested at Amazon by hundreds of services in production, most of them using backports of the feature to JDK 21 and JDK 17.

Various experiments demonstrate that enabling compact object headers improves performance:

  - In one setting, the SPECjbb2015 benchmark uses [22% less heap space and 8% less CPU time][kennke].
  - In another setting, the number of garbage collections done by SPECjbb2015 is [reduced by 15%][johansson], with both the G1 and Parallel collectors.
  - A highly parallel JSON parser benchmark [runs in 10% less time][json].

It is time to make compact object headers the default mode of operation and deprecate the old object header layout.

[kennke]: https://github.com/rkennke/talks/blob/master/Lilliput-FOSDEM-2025.pdf
[johansson]: https://bugs.openjdk.org/browse/JDK-8350457?focusedId=14766358&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14766358
[json]: https://www.reddit.com/r/scala/comments/1jptiv3/xxusecompactobjectheaders_is_your_new_turbo/?rdt=40432


Description
-----------

Compact object headers are enabled in JDK 25 via the command-line options

    $ java -XX:+UseCompactObjectHeaders ...

That option, `-XX:+UseCompactObjectHeaders`, will no longer be needed once they are the default. Instead, if, for any reason, the feature needs to be turned off, it can be done by running with:

    $ java -XX:-UseCompactObjectHeaders ...

Testing
-------

Compact object headers were subjected to massive testing as part of [JEP 450](https://openjdk.org/jeps/450#Testing) and [JEP 519](https://openjdk.org/jeps/519#Testing).  Another full set of correctness and performance testing is run before intergration of this JEP.


Risks and Assumptions
---------------------

As discussed in [JEP 450](https://openjdk.org/jeps/450#Risks-and-Assumptions), future features may require additional object-header bits. We have already reserved four bits for [Project Valhalla](https://openjdk.org/projects/valhalla/). If a need for even more bits arises then we can shrink compressed class pointers and identity hash codes even further, using techniques we have already prototyped in [Project Lilliput](https://wiki.openjdk.org/display/lilliput).