I have a hard time understanding how compressed pointers works in Java 19, help is appreciated.
In Java 11 the reference size is 4 for heaps below 32GiB (compressed pointers) and 8 for a larger heap. In Java 19 they seem to take 4 bytes even for larger heaps (how?).
Details:
Java versions: OpenJDK Java 11.0.12 and OpenJDK Java 19.0.1
Command lines:
-XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xlog:gc -Xlog:gc+heap+coops -Xms41g -Xmx41g -XX:+AlwaysPreTouch
-XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xlog:gc -Xlog:gc+heap+coops -Xms31g -Xmx31g -XX:+AlwaysPreTouch
Code: https://github.com/cornelcreanga/fun/blob/master/src/main/java/com/ccreanga/various/RandomAllocate.java - the code is taken from https://shipilev.net/jvm/anatomy-quarks/23-compressed-references/
Run this code with both Java 11 and 19 and you can see that the memory size is lower in Java 19 than in Java 11 for a heap > 32 GiB. For a smaller heap the size is almost identical.