Skip to content
Advertisement

In Hotspot JVM, why CDS needs Compressed Oops?

I read this post “https://malloc.se/blog/zgc-jdk15”, and last index is about Class Data Sharing. In this index,

This feature(means CDS) only work when the Compressed Oops feature was enable(-XX:+UseCompressedOops).

I know about CDS and Compress Oops a little, but I cant understand about their relationship.

Advertisement

Answer

CDS (Class Data Sharing) does not need Compressed OOPs. However, before JDK 15, it worked only in the default configuration, where UseCompressedOops=true and UseCompressedClassPointers=true.

The problem and the solution is described in JDK-8232069.

For CDS archive to be valid, the runtime values of UseCompressedOops and UseCompressedClassPointers must match the values used during archive generation. Before JDK-8232069, the values were not saved in the archive, and the JVM assumed that the Compressed OOPs were turned on (the default). As a consequence, CDS was not compatible with ZGC, because ZGC requires Compressed OOPs to be turned off.

To make CDS compatible with ZGC, JDK-8232069 made the values of UseCompressedOops and UseCompressedClassPointers written to the archive, and when the JVM starts, it checks if the current flags match those saved values. So now (since JDK 15) CDS works with either configuration of Compressed OOPs, and now it is compatible with ZGC.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement