Sandeep Kaul
Sandeep Kaul

Reputation: 3267

Why is -XX:+UseCompressedOops not defaulted, and not always used?

Wanted to know is there any situation in which using -XX:+UseCompressedOops would be un-optimal? Looks like there is a lot of benefit in using this option.

Upvotes: 1

Views: 1661

Answers (2)

the8472
the8472

Reputation: 43115

Why is [...] not defaulted

Many settings in the hotspot JVM are auto-configured based on various system properties and also based on other parameters. So there does not exist one fixed set of defaults.

To see which flags are really applied you can add -XX:+PrintFlagsFinal, which will show compressed oops being on under some circumstances.

$ java -Xmx64g -XX:+PrintFlagsFinal | grep UseCompressedOops
     bool UseCompressedOops                         = false                               {lp64_product}
$ java         -XX:+PrintFlagsFinal | grep UseCompressedOops
     bool UseCompressedOops                        := true                                {lp64_product}

Upvotes: 0

Kayaman
Kayaman

Reputation: 73568

Looks like you're not the first one to think that. According to this it's on unless you're using over 32GB heaps.

Disabling it would be a rare edge case, such as a workaround for a bug or similar thing.

Importance of this option can also be realized by fact that from Java 6 update 18 Oracle by default enable -XX:+UseCompressedOops in HotSpot JVM based upon maximum Java heap size.

Upvotes: 1

Related Questions