October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Java 25 Compact Object Headers: What One Benchmark Actually Saved

Oracle documents 64-bit Compact Object Headers in Java 25, but actual heap savings depend on the workload. One author-reported OrderLine benchmark found about 15.95 bytes per sample instance across three heap objects.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

-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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

How to enable the option in Java 25

For a Java 25 HotSpot process, add this JVM argument:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
-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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to measure the effect in your own workload

  1. 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.
  2. 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.
  3. 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.
  4. Repeat the runs. Record the runtime build and configuration, measurement method, and repeated results so that differences can be interpreted in context.
  5. 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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.