Could you give me some information on what is exactly stored in object header? I know, that it's probably JVM dependent, but maybe for HotSpot at least? I'm looking for exact description specifically for a first row.
I've read several information that I can't verify positively with information I find. Maybe you have a link to OpenJDK wiki that says it all?
For HotSpot:
The object header consists of a mark word and a klass pointer.
The mark word has word size (
4 byteon 32 bit architectures,8 byteon 64 bit architectures) andthe klass pointer has word size on
32 bitarchitectures. On64 bitarchitectures the klass pointer either has word size, but can also have4 byteif the heap addresses can be encoded in these4 bytes.This optimization is called "compressed oops" and you can also control it with the option
UseCompressedOops.You can also find a wiki entry about this 1.
The mark word is actually used for many things.
Biased Locking2 through which HotSpot can implement efficient locking.GC to set forward pointers, andto store the age of the objects. The identity hash code of an object can be stored inside the mark (theSystem.identityHashCode/Object.hashCodeone).There is a comment in the source code of markOop.hpp that describes the layout depending on the architecture:
You can also find the oop header file here.