Sundararajan's Weblog

  • Java
    April 26, 2006

Turning on/off and viewing JVM flags dynamically

Guest Author

As I mentioned in my

http://blogs.sun.com/roller/page/sundararajan?entry=dtrace_java_turning_on_off">last blog entry, jinfo tool may be used to turn (a subset of) JVM command line flags dynamically. As examples, I cited turning on/off verbose GC tracing and class loading tracing. jconsole
may also be used to turn on verbose GC and verbose class modes.

jconsole to turn on/off verbose:class mode

You can use "Verbose Output" checkbox in "Classes" tab.

jconsole to turn on/off verbose:gc mode

This is little tricky! In "MBeans" tab, choose "java.lang"->"Memory" in tree and then you see "Verbose" attribute of Memory MBean. Here, you can change the value to
false or true.

Using HotSpotDiagnosticMXBean with jconsole

can be directly accessed and controlled from jconsole. In "MBeans" tab, choose com.sun.management->HotSpotDiagnoticMXBean in the tree and then choose
"operations" menu in right panel. From this right panel, you can invoke getVMOption and setVMOption operations on HotSpotDiagnosticMXBean and thereby explicitly manage any manageable JVM flag. Also, this can be used to dump heap (dumpHeap operation - to which heap dump file name can be passed as an argument)

Viewing the value of any JVM -XX flag

jinfo can be used to view value of any JVM -XX flag (whether or not that flag is manageable - i.e., dynamically turnable or not).

jinfo -flag <flag-name> <java-pid>

This is particularly useful if you use many of the -XX JVM flags.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.