What does the HotSpot JVM flag -XX:+UseCompressedOops
do and when should I use it? What sort of performance and memory-usage differences will I see when using it on a 64-bit Java instance (vs. not using it)?
-XX:+UseCompressedOops enables the use of compressed 32 bit OOPS in 64 bit JVM which effectively compensates the performance penalty imposed by 64 bit JVM without scarifying heap size advantage offered by them.
The -XX:+UseCompressedOops option enables compressed references in 64-bit JVMs. The -XX:+UseCompressedOops option is similar to specifying -Xcompressedrefs, which is detailed in the topic JVM command-line options. The -XX:-UseCompressedOops option prevents the use of compressed references in 64-bit JVMs.
The 64-bit JVM is especially useful for Java applications with large heaps, such as those that use more than 100 GB of memory as a maximum. Because the size of the OOP (Ordinary Object Pointer) has increased from 32 to 64 bits, the same Java application will use more memory in the 64-bit JVM than in the 32-bit JVM.
Most HotSpot JVM in the last year have had it on by default. This option allows references to be 32-bit in a 64-bit JVM and access close to 32 GB of heap. (more than 32-bit pointers can) (You can have near unlimited off heap memory as well). This can save a significant amount of memory and potentially improve performance.
If you want to use this option I suggest you update to a version which has it on by default as there may have been a good reason, such as bugs, why it wasn't enabled previously. Try Java 6 update 23 or Java 7 update 5.
In short, don't turn it on, use a version which has it on by default.
Update:
In Java 8 you have the option to set the -XX:ObjectAlignmentInBytes=
and in fact if you heap size to 64 GB it will use -XX:ObjectAlignmentInBytes=16
and still use 32-bit references.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With