JVM Memory Layout Terminology: OOPs and Compressed OOPs
This page explains the terms that appear in JVM memory-layout discussions, Garbage Collector (GC) logs, error messages, and tuning flags, and how Azul Zing Builds of OpenJDK (Zing) handles them compared to OpenJDK and Azul Zulu.
Ordinary Object Pointer (OOP)
An ordinary object pointer (OOP) is the JVM’s internal term for a reference to an object in the Java heap. Every field or array element of an object type, every local variable holding an object, and every reference on a thread stack is an OOP. The term oop is also used in HotSpot source code, flag names, and log messages.
Compressed OOPs (Compressed References)
On a 64-bit JVM, a native pointer is 8 bytes (64 bits). Compressed OOPs, also called compressed references or compressed object pointers, store an object reference in 4 bytes (32 bits) instead of 8 bytes (64 bits). The JVM encodes the reference by shifting it according to the object alignment, and decodes it when the reference is used.
In OpenJDK and Azul Zulu:
-
Compressed OOPs are enabled by default on 64-bit JVMs when the maximum heap size is small enough, which is a little under 32 GB with the default object alignment of 8 bytes. Above that limit, the JVM falls back to 64-bit pointers.
-
The flag
-XX:+UseCompressedOopsenables the feature.-XX:-UseCompressedOopsdisables it. -
-XX:ObjectAlignmentInByteschanges the alignment, which changes the maximum heap size that can still use compressed OOPs. -
-XX:+UseCompressedClassPointersis a related flag that compresses the pointers to class metadata.
Smaller references reduce the heap footprint and improve cache efficiency, which is why an OpenJDK heap just below the limit can perform better than one just above it.
Compressed OOPs aren’t supported with ZGC in OpenJDK.
Compressed OOPs in Azul Prime
Zing doesn’t use compressed OOPs. All pointers are 8 bytes (64 bits), and UseCompressedOops is false by default. This is the same as with ZGC in OpenJDK. On memory-constrained environments, this can cause differences in memory usage and application performance compared to OpenJDK or Zulu with another GC that uses compressed OOPs.
The Zing heap isn’t limited to the size at which compressed OOPs stop working, so you don’t need to keep the heap below 32 GB. See Recommended Heap Size for the supported heap sizes.
C4 and ZGC don’t physically separate young (new) generation objects from old generation objects. This gives more flexibility in using the whole Java heap, which partly compensates for the absence of compressed OOPs.
When you compare the memory usage of Zing with another JVM, take this difference into account, together with the other differences described in Memory Usage.
Object Headers and Compact Object Headers
Every Java object starts with an object header that holds the object’s lock and GC state (the mark word) and a pointer to its class. With compressed class pointers, the header is 12 bytes on a 64-bit OpenJDK JVM. Starting with JDK 25, JEP 519 (compact object headers) can reduce the header to 8 bytes with -XX:+UseCompactObjectHeaders. This is separate from compressed OOPs, which shrink object references, but both reduce the memory used per object.
Zing has always used a compact object header: the header of a non-array object is 8 bytes. Compact object headers therefore need no flag in Zing, and -XX:+UseCompactObjectHeaders is ignored.
Related Terms
| Term | Meaning |
|---|---|
OOP |
Ordinary object pointer: a reference to an object in the Java heap. |
Compressed OOP |
A 4-byte (32-bit) encoded object reference used by OpenJDK and Zulu for heaps below the size limit. Not supported with ZGC in OpenJDK, and not used by Zing (C4). |
Object header |
The metadata at the start of every object: the mark word and a pointer to the object’s class. See Object Headers and Compact Object Headers. |
Klass |
The JVM’s internal representation of a loaded class. In Zing, the KlassTable holds a unique ID for each loaded class. See Troubleshooting Application Errors if the table runs out of space. |