Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What does an object header contain in 64-bit HotSpot, and what information does the mark word hold?

In 64-bit HotSpot, every object starts with a header made of an 8-byte mark word and a class pointer, which is 4 bytes with compressed class pointers, so the header is 12 bytes before padding; arrays add a 4-byte length. The mark word holds the identity hash code once it has been computed, the GC age bits that count how many collections the object survived, and bits describing its locking state; since biased locking was disabled in JDK 15 and later removed, it no longer stores a biased owner. Compact object headers, product but off by default in JDK 25, fit the whole header into 8 bytes.

Why this question is asked

Every Java object pays for its header, so a service holding a hundred million small objects spends more than a gigabyte on headers alone. The header is also where the JVM keeps the information that makes hash codes, garbage collection and synchronized work. Interviewers ask about it to see whether we understand what an object costs and what happens inside the JVM when we lock or hash one. In this answer, we will look at the parts of a header, go through what the mark word holds and how it changes, see what happened to biased locking, and look at compact object headers.

1The Parts of an Object Header

On a 64-bit JVM with default settings, an object's memory starts with two pieces of bookkeeping. The mark word, 8 bytes, holds per-object runtime state. The class pointer, also called the klass pointer, tells the JVM which class the object belongs to. With compressed class pointers, which are on by default, it is 4 bytes, so the header is 12 bytes. Fields follow, and the whole object is padded to a multiple of 8 bytes. Arrays have one more header field, a 4-byte length.

Layout of a plain object and an array
Offsetnew Object()new int[3]
0-7mark wordmark word
8-11class pointer (compressed)class pointer (compressed)
12-15padding to 16 bytesarray length = 3
16-27-three int elements
28-31-padding to 32 bytes
Total16 bytes32 bytes

2What the Mark Word Holds

The mark word is small but busy. In its normal, unlocked state it holds the identity hash code, 31 bits, which is computed lazily the first time someone asks for it and then stored so it never changes. It holds 4 bits of GC age, which young collections increment each time the object survives; when the age reaches the tenuring threshold, at most 15, the object is promoted to the old generation. And it holds lock bits that tell the JVM whether the object is unlocked, locked, or linked to a heavier monitor structure.

When an object is locked in a way that needs more state, for example when threads contend for it or call wait(), the JVM inflates the lock to an ObjectMonitor, a separate native structure, and the mark word points to it. The displaced hash and age live there until the lock is deflated again.

3Seeing It With JOL

The Java Object Layout tool, JOL, prints an object's header and fields as the running JVM lays them out. It shows the mark word changing when we compute a hash code.

Java
Object o = new Object();
System.out.println(ClassLayout.parseInstance(o).toPrintable());
// OFF SZ TYPE DESCRIPTION VALUE
// 0 8 (object header: mark) 0x0000000000000001 (non-biasable; age: 0)
// 8 4 (object header: class) 0x00000d58
// 12 4 (object alignment gap)
// Instance size: 16 bytes
int h = System.identityHashCode(o);
System.out.println(ClassLayout.parseInstance(o).toPrintable());
// 0 8 (object header: mark) 0x0000005b6f741201 (hash: 0x5b6f7412; age: 0)
// (values differ per run)

Notice that the hash appears in the mark word only after we asked for it. Before that, the bits are zero, because computing and storing a hash for every object would waste time on objects that are never hashed.

4What Happened to Biased Locking

Biased locking was an optimisation for objects that are only ever locked by one thread. The first thread to lock the object wrote its own thread id into the mark word, and from then on it could lock and unlock without any atomic instruction. When another thread came along, the JVM had to revoke the bias, which needed a safepoint and was expensive.

Modern code locks far less on shared objects than the old collections did, and revocation made the JVM complex and pauses unpredictable. JDK 15 disabled biased locking by default (JEP 374), and later releases removed it altogether. So in current JDKs the mark word never holds a biased owner, and an uncontended synchronized uses a lightweight locking scheme instead. The details of that scheme have changed in recent releases, so check your version if you need them.

5Compact Object Headers

Project Lilliput set out to shrink the header. JEP 450 added compact object headers as an experimental feature in JDK 24, and in JDK 25 they became a product feature, still off by default. With -XX:+UseCompactObjectHeaders, the class pointer is squeezed into the mark word itself, so the whole header fits in 8 bytes instead of 12.

Shell
java -XX:+UseCompactObjectHeaders -jar app.jar # JDK 25, product flag, off by default
# JDK 24 also needed: -XX:+UnlockExperimentalVMOptions
// An Integer: 12-byte header + 4-byte int = 16 bytes with standard headers
// 8-byte header + 4-byte int = 12, padded to 16 bytes with compact headers
// An object with two int fields: 12 + 8 = 20 -> 24 bytes, compact: 8 + 8 = 16 bytes

Notice that the saving shows up only when the 4 bytes cross an 8-byte boundary. For heaps full of small objects, the overall reduction is often in the range of 10 to 20 percent, but it depends on the object sizes, so it has to be measured.

6Follow-up questions

Why does calling System.identityHashCode affect an object's header?

Because the identity hash is not stored anywhere until it is first requested. The first call generates a value and writes it into the mark word, so that every later call returns the same number even if the GC moves the object to a new address. From then on, those header bits are taken. In the days of biased locking, this also meant the object could never be biased again, because the bias and the hash used the same bits; computing a hash on a biased object forced a revocation. Overriding hashCode() in our class does not touch the header, because only the identity hash is stored there.

How big is the header without compressed class pointers?

16 bytes: an 8-byte mark word and an 8-byte class pointer. Compressed class pointers are on by default and are independent of compressed oops in current JDKs, so even large heaps normally keep the 12-byte header.

Where does the GC age come from, and why is the maximum 15?

Each young collection that copies a surviving object increments its age in the mark word. There are only 4 bits for it, so the largest age is 15, which is why MaxTenuringThreshold cannot be set higher.

7Conclusion

In this answer, we saw that a 64-bit HotSpot object header has an 8-byte mark word and a class pointer, 4 bytes when compressed, giving 12 bytes before padding, plus a length for arrays. The mark word holds the identity hash once computed, 4 bits of GC age and the locking state, and no longer holds a biased owner since biased locking was disabled in JDK 15 and later removed. Compact object headers, product but off by default in JDK 25, shrink the header to 8 bytes.

What to say in the interviewAbout 90 seconds aloud

Open with

On 64-bit HotSpot an object header has two parts. First the mark word, which is 8 bytes, and then the class pointer, which says what class the object is.

Then, if they want more

With compressed class pointers, which are the default, that pointer is 4 bytes, so the header is 12 bytes and then the object is padded to a multiple of 8, which is why new Object takes 16 bytes. Arrays also store a 4-byte length after the class pointer. The mark word holds runtime state.

It has the identity hash code, but only once someone has asked for it, because it is computed lazily and then stored so it never changes even when the GC moves the object. It has 4 bits of GC age, counting how many young collections the object survived, which is why the tenuring threshold maxes out at 15.

And it has the lock bits; if the lock is inflated because of contention or wait, the mark word points to a separate monitor structure. It used to also hold the owning thread for biased locking, but biased locking was disabled by default in JDK 15 and later removed, so that is gone.

The newest change is compact object headers from Project Lilliput: experimental in JDK 24 and a product option in JDK 25, off by default, they fold the class pointer into the mark word so the whole header is 8 bytes.

About this answer

Last updated
12 November 2026
Versions it names
Java 25, Java 15, Java 24
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What does an object header contain in 64-bit HotSpot, and what information does the mark...": https://scrivio-interview-library.netlify.app/java/memory-layout/4b279f3432/