Created
November 2, 2011 06:38
-
-
Save rednaxelafx/1333043 to your computer and use it in GitHub Desktop.
UseCompressedOops ergonomics for Oracle/Sun JDK 6 on x64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.lang.management.*; | |
import com.sun.management.*; | |
public class CheckCompressedOopsMode { | |
private static final String HOTSPOT_BEAN_NAME = "com.sun.management:type=HotSpotDiagnostic"; | |
private static HotSpotDiagnosticMXBean hotspotMBean; | |
private static HotSpotDiagnosticMXBean getHotSpotMBean() { | |
if (hotspotMBean == null) { | |
try { | |
hotspotMBean = ManagementFactory.newPlatformMXBeanProxy( | |
ManagementFactory.getPlatformMBeanServer(), | |
HOTSPOT_BEAN_NAME, | |
HotSpotDiagnosticMXBean.class); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
return hotspotMBean; | |
} | |
public static String getJavaVersion() { | |
return System.getProperty("java.version"); | |
} | |
public static void printJavaVersionOn(PrintStream out) { | |
out.println(getJavaVersion()); | |
} | |
public static String getJvmVersion() { | |
return System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version"); | |
} | |
public static void printJvmVersionOn(PrintStream out) { | |
out.println(getJvmVersion()); | |
} | |
public static VMOption getUseCompressedOopsVMOption() { | |
return getHotSpotMBean().getVMOption("UseCompressedOops"); | |
} | |
public static boolean isUseCompressedOops() { | |
return Boolean.valueOf(getUseCompressedOopsVMOption().getValue()); | |
} | |
public static void printCompressedOopsModeOn(PrintStream out) { | |
try { | |
VMOption op = getUseCompressedOopsVMOption(); | |
out.println("Using compressed oops: " + op.getValue() + | |
", origin: " + op.getOrigin()); | |
} catch (IllegalArgumentException e) { | |
out.println("This VM doesn't support UseCompressedOops"); | |
} catch (NullPointerException e) { | |
out.println("This VM doesn't support UseCompressedOops"); | |
} | |
} | |
public static void main(String[] args) { | |
PrintStream out = System.out; | |
printJavaVersionOn(out); | |
printJvmVersionOn(out); | |
printCompressedOopsModeOn(out); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ jdk/6u17_x64/bin/java Che17_x64/bin/java CheckCompressedOopsMode | |
1.6.0_17 | |
Java HotSpot(TM) 64-Bit Server VM 14.3-b01 | |
Using compressed oops: false, origin: DEFAULT | |
$ jdk/6u18_x64/bin/java CheckCompressedOopsMode | |
1.6.0_18 | |
Java HotSpot(TM) 64-Bit Server VM 16.0-b13 | |
Using compressed oops: false, origin: DEFAULT | |
$ jdk/6u19_x64/bin/java CheckCompressedOopsMode | |
1.6.0_19 | |
Java HotSpot(TM) 64-Bit Server VM 16.2-b04 | |
Using compressed oops: false, origin: DEFAULT | |
$ jdk/6u20_x64/bin/java CheckCompressedOopsMode | |
1.6.0_20 | |
Java HotSpot(TM) 64-Bit Server VM 16.3-b01 | |
Using compressed oops: false, origin: DEFAULT | |
$ jdk/6u21_x64/bin/java CheckCompressedOopsMode | |
1.6.0_21 | |
Java HotSpot(TM) 64-Bit Server VM 17.0-b17 | |
Using compressed oops: false, origin: DEFAULT | |
$ jdk/6u22_x64/bin/java CheckCompressedOopsMode | |
1.6.0_22 | |
Java HotSpot(TM) 64-Bit Server VM 17.1-b03 | |
Using compressed oops: false, origin: DEFAULT | |
$ jdk/6u23_x64/bin/java CheckCompressedOopsMode | |
1.6.0_23 | |
Java HotSpot(TM) 64-Bit Server VM 19.0-b09 | |
Using compressed oops: true, origin: ERGONOMIC | |
$ jdk/6u24_x64/bin/java CheckCompressedOopsMode | |
1.6.0_24 | |
Java HotSpot(TM) 64-Bit Server VM 19.1-b02 | |
Using compressed oops: true, origin: ERGONOMIC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can't use jinfo -flag {flag name} pid to inspect the vm args?