Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change JVM JIT Options at runtime

Is it possible to change options and/or modes of Java JVM (JIT) at runtime? E.g. change XX:CompileThreshold, or even switch between interpreted and compiled code (-Xcomp vs -Xint).

My JVM is from OpenJDK (1.6), Hotspot or Zero/Shark

like image 998
osgx Avatar asked Dec 27 '22 02:12

osgx


1 Answers

You cannot change the JVM mode at runtime, however you can modify some flags without restarting the JVM. Just connect to the JVM using a JMX client (like VisualVM) and use the operation setVMOption of com.sun.management:type=HotSpotDiagnostic.

For instance, if you want to enable detailed GC logging without restarting the JVM, call the method setVMOptions("PrintGCDetails", "true").

Source : http://docs.oracle.com/javase/6/docs/jre/api/management/extension/com/sun/management/HotSpotDiagnosticMXBean.html#setVMOption%28java.lang.String,%20java.lang.String%29

Hope that helps !

like image 71
Pierre Laporte Avatar answered Jan 10 '23 11:01

Pierre Laporte