The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →-XX:+UseCompactObjectHeaders can reduce HotSpot object headers in Java 25, but it does not guarantee a fixed heap reduction for every application. Oracle documents a header-size change from 96 or 128 bits to 64 bits. In one author-reported OrderLine benchmark, the measured difference was about 15.95 bytes per instance—but that figure included three heap objects, not just one object header.
What Compact Object Headers change
In Oracle’s Java SE 25 GC Tuning Guide, Compact Object Headers reduce an object header from 96 or 128 bits to 64 bits. That is a raw header reduction of four bytes for a 12-byte header or eight bytes for a 16-byte header.
As an Amazon Associate I earn from qualifying purchases.
Those arithmetic differences are not a prediction of how much an application’s heap will shrink. An object’s total footprint also depends on its fields, references, alignment, and the kinds and number of objects that remain live. Arrays and the rest of the object graph matter too. Multiplying the header reduction by a total object count therefore does not establish actual heap savings.
What the reported benchmark found
Avaneesh Yadav’s September 29, 2026, BuildingAI.in article reports two runs of an OrderLine sample using Temurin JDK 25.0.3 and a fixed 4 GiB initial and maximum heap. The reported measurements were:
| Run | Without compact headers | With compact headers | Difference |
|---|---|---|---|
| First | 164.19 bytes per OrderLine-shaped instance | 148.25 bytes per OrderLine-shaped instance | 15.94 bytes |
| Repeat | 164.20 bytes per OrderLine-shaped instance | 148.21 bytes per OrderLine-shaped instance | 15.99 bytes |
The article summarizes the saving as approximately 15.95 bytes per instance. Its measured unit includes three heap objects—the OrderLine DTO and two Strings it owns—so the result is an aggregate for that sample’s object shape. It is not evidence that each Java object saves 15.95 bytes, nor a universal per-instance or application-wide saving.
These are the article author’s reported measurements, not an independently reproduced benchmark. The article also describes a primitives-only variant, but its output is not established here, so no result for that variant can be stated.
Rank #2
How to enable the option in Java 25
For a Java 25 HotSpot process, add this JVM argument:
-XX:+UseCompactObjectHeaders
Oracle says the option is disabled by default in JDK 25. In that release, it is a product option, so enabling it does not require -XX:+UnlockExperimentalVMOptions. To compare with ordinary headers explicitly, use -XX:-UseCompactObjectHeaders.
Oracle also documents two additional CDS archives, classes_coh.jsa and classes_nocoops_coh.jsa, to support equivalent startup performance when Compact Object Headers is enabled. Account for the runtime’s CDS configuration when assessing startup behavior.
Check whether your application is a fit
Oracle documents a limit of four million different loaded classes when Compact Object Headers is enabled. Applications that generate or load unusually large numbers of classes should validate their class-loading behavior against that limit before adopting the option.
Rank #4
Oracle describes reduced Java heap footprint and says enabling the feature “potentially provides performance benefits.” Potential is not a guarantee: the documented feature does not establish a universal heap-saving percentage, throughput gain, or latency improvement across workloads.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsHow to measure the effect in your own workload
- Use a controlled comparison. Keep the application, JDK vendor and build, machine, heap sizing, garbage collector, inputs, and run procedure the same. Toggle only the compact-header option.
- Measure memory and performance. Compare live heap or retained object sizes as well as throughput and latency; a smaller object footprint alone does not establish a performance improvement.
- Use representative objects and workloads. Include the object shapes and live object graph that matter in production. Header size is only one component of total footprint.
- Repeat the runs. Record the runtime build and configuration, measurement method, and repeated results so that differences can be interpreted in context.
- Validate class loading and startup. Check the documented loaded-class limit and confirm that your CDS setup is appropriate for the enabled mode.
The useful result is the one from that controlled comparison: whether the option reduces retained memory in your workload without unacceptable changes to throughput, latency, startup, or class loading.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




