โ— Shell
clean mode source โ†—

Compact object headers

Code Comparison

// Default: 128-bit object header
// = 16 bytes overhead per object
// A boolean field object = 32 bytes!
// Mark word (64) + Klass pointer (64)
// -XX:+UseCompactObjectHeaders
// 64-bit object header
// = 8 bytes overhead per object
// 50% less header memory
// More objects fit in cache

Why the modern way wins

๐Ÿ“ฆ

50% smaller headers

8 bytes instead of 16 per object.

โšก

Better cache usage

More objects fit in CPU cache lines.

๐Ÿ“Š

Higher density

Fit more objects in the same heap size.

Old Approach

128-bit Headers

Modern Approach

64-bit Headers

JDK Support

Compact object headers

Available

Finalized in JDK 25 LTS (JEP 519, Sept 2025).

How it works

Compact object headers reduce the per-object overhead from 128 bits to 64 bits on 64-bit platforms. This saves memory and improves cache utilization, especially for applications with many small objects.

Related Documentation