Changing JVM JIT Parameters at Run Time

Is it possible to change Java JVM parameters and / or modes (JIT) at runtime? For instance. 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

+4
source share
2 answers

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

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

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 this helps!

+7
source

You can change some of these parameters using MBeans .

Most of them are read-only.

+2
source

Source: https://habr.com/ru/post/1483813/


All Articles