JVM Anatomy Quarks: Compressed References

JVM Anatomy Quarks: Compressed References

In Hotspot, the references to Java objects are called “ordinary object pointers”, or “oops”, which is why Hotspot VM options have these weird names: -XX:+UseCompressedOops , -XX:+PrintCompressedOopsMode , -Xlog:gc+heap+coops . Now, the reference field only takes 4 bytes and the instance size is down to 16 bytes:

This whole shebang is obviously possible when heap size is less than 4 GB (or, 2 32 bytes). The easiest way to do that is to bit-shift-right the reference bits, and this gives us 2(32+shift) bytes of heap encodeable into 32 bits.

Source: shipilev.net