Is it possible to get the current value of the JVMs CompileThreshold during runtime?
If it was set manually I can get it form the VM Arguments. Otherwise I may assume default values (e.g. 10,000 for Oracles HotSpot on Servers), but this might not be correct. Is there are better way?
The purpose is to "preheat" some functions during startup.
You can retrive this information from the HotSpotDiagnosticMXBean
.
static final String HOTSPOT_BEAN_NAME = "com.sun.management:type=HotSpotDiagnostic";
public static void main(String[] args) throws Exception {
Class clazz = Class.forName("com.sun.management.HotSpotDiagnosticMXBean");
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
HotSpotDiagnosticMXBean bean = (HotSpotDiagnosticMXBean) ManagementFactory
.newPlatformMXBeanProxy(server, HOTSPOT_BEAN_NAME, clazz);
VMOption vmOption = bean.getVMOption("CompileThreshold");
System.out.printf("%s = %s%n", vmOption.getName(), vmOption.getValue());
}
output
CompileThreshold = 10000