Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Getting the HeapOopSize through sun.misc.Unsafe. Refer to http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2012-March/007445.html
D:\experiment>java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)
D:\experiment>groovysh
Groovy Shell (1.8.4, JVM: 1.6.0_30)
Type 'help' or '\h' for help.
---------------------------------------------------------------------------------------------------
groovy:000> sun.misc.Unsafe.theUnsafe.arrayIndexScale(Object[].class)
===> 4
groovy:000> sun.misc.Unsafe.theUnsafe.arrayBaseOffset(Object[].class)
===> 16
groovy:000> quit
D:\experiment>set JAVA_OPTS=-XX:-UseCompressedOops
D:\experiment>groovysh
Groovy Shell (1.8.4, JVM: 1.6.0_30)
Type 'help' or '\h' for help.
---------------------------------------------------------------------------------------------------
groovy:000> sun.misc.Unsafe.theUnsafe.arrayIndexScale(Object[].class)
===> 8
groovy:000> sun.misc.Unsafe.theUnsafe.arrayBaseOffset(Object[].class)
===> 24
groovy:000> quit
D:\experiment>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.