Skip to content

Instantly share code, notes, and snippets.

@rednaxelafx
Created May 29, 2011
Embed
What would you like to do?
Example of HotSpot's PrintCompressedOopsMode's output. It's clear that UseCompressedOops can only be used with heap size < 32GB
rednaxelafx@fx-laptop:~$ java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
rednaxelafx@fx-laptop:~$ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode Noop
heap address: 0x000000077fe00000, size: 2050 MB, zero based Compressed Oops
rednaxelafx@fx-laptop:~$ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode -Xmx6g Noop
heap address: 0x000000067ae00000, size: 6226 MB, zero based Compressed Oops
rednaxelafx@fx-laptop:~$ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode -Xmx12g Noop
heap address: 0x00000004fae00000, size: 12370 MB, zero based Compressed Oops
rednaxelafx@fx-laptop:~$ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode -Xmx24g Noop
heap address: 0x00000001fae00000, size: 24658 MB, zero based Compressed Oops
$ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode -Xmx28g Noop
heap address: 0x00000000fae00000, size: 28754 MB, zero based Compressed Oops
rednaxelafx@fx-laptop:~$ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode -Xmx32g Noop
rednaxelafx@fx-laptop:~$ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode -Xmx31g Noop
Protected page at the reserved heap base: 0x00007f21099d0000 / 65536 bytes
heap address: 0x00007f21099e0000, size: 31826 MB, Compressed Oops with base: 0x00007f21099df000
rednaxelafx@fx-laptop:~$ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode -Xmx128m Noop
heap address: 0x00000000f2e00000, size: 210 MB, zero based Compressed Oops, 32-bits Oops
rednaxelafx@fx-laptop:~$ java -Xmx64g -XX:+UseCompressedOops Noop
Java HotSpot(TM) 64-Bit Server VM warning: Max heap size too large for Compressed Oops
rednaxelafx@fx-laptop:~$ java -Xmx64g -XX:+UseCompressedOops -XX:+PrintFlagsFinal Noop | grep CompressedOops
bool UseCompressedOops := false {lp64_product}
The "size" field shows total reserved GC heap size in MB, which includes all generations (including PermGen).
"32-bits Oops" means the shift is zero; otherwise it'd be non-zero.
If UseCompressedOops is false, or if the heap is too big to use compressed oops, then PrintCompressedOopsMode won't print anything. The -Xmx32g example below show that ergonomics didn't set UseCompressedOops to true.
If the heap is too big, HotSpot would print a warning message and set UseCompressedOops to false.
@ecki
Copy link

ecki commented Feb 26, 2014

In my case the 32bit oops (no shifting) go up to 1970m (Win7x64):

C:\Users\Eckenfel>"c:\Program Files\Java\jdk1.7.0\bin\java.exe" -Xmx1960m -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode -version

heap address: 0x0000000080600000, size: 2042 MB, zero based Compressed Oops, 32-bits Oops

java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b16)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

C:\Users\Eckenfel>"c:\Program Files\Java\jdk1.7.0\bin\java.exe" -Xmx1970m -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode -version

heap address: 0x000000077fc00000, size: 2052 MB, zero based Compressed Oops

java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b16)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment