Java Tool Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 5.11

Changing HotSpot VM Option using 'jinfo'

This section provides a tutorial example on how to set a new value to a HotSpot VM option on a given JVM process using the 'jinfo' tool.

The "jinfo" tool can be used to view the current value of any HotSpot VM option of a given JVM process as described in the previous section.

The "jinfo" tool can also be used set a new value of any HotSpot VM option using the "jinfo -flag name=value" format. Here is what I did to test this function with JDK 1.6 on a Windows system:

C:\herong>\Progra~1\java\jdk1.6.0_02\bin\java -XX:ThreadStackSize=512
   -jar "\Program Files\java\jdk1.6.0_02\demo\jfc\Notepad\notepad.jar"
   (Notepad started)


(Start another command window.)
C:\herong>\Progra~1\java\jdk1.6.0_02\bin\jps -l -m

1424 \Program Files\java\jdk1.6.0_02\demo\jfc\Notepad\notepad.jar
3124 sun.tools.jps.Jps -l -m


C:\herong>\Progra~1\java\jdk1.6.0_02\bin\jinfo 
   -flag ThreadStackSize 1424

-XX:ThreadStackSize=512


C:\herong>\Progra~1\java\jdk1.6.0_02\bin\jinfo 
   -flag ThreadStackSize=1024 1424
   
Exception in thread "main" java.io.IOException: 
   Command failed in target VM
   at sun.tools.attach.WindowsVirtualMachine.execute
      (WindowsVirtualMachine.java:94)
   at sun.tools.attach.HotSpotVirtualMachine.executeCommand
      (HotSpotVirtualMachine.java:195)
   at sun.tools.attach.HotSpotVirtualMachine.setFlag
      (HotSpotVirtualMachine.java:172)
   at sun.tools.jinfo.JInfo.flag(JInfo.java:105)
   at sun.tools.jinfo.JInfo.main(JInfo.java:58)

Apparently, the target VM (the Notepad VM) does not allow me to change its option. I do not know why?

Sections in This Chapter

JVM Troubleshooting Tools in JDK 1.5

'jinfo' - VM Option Value Checker

Changing HotSpot VM Option using 'jinfo'

'jstack' - Stack Tracer of JVM Threads

Java Thread Deadlock Demo Program

Detecting Java Thread Deadlocks with 'jstack'

'jmap' - JVM Heap Dump Tool

Printing Histogram of Java Object Heap

Generating Heap Dump File with 'jmap'

'jhat' - Java Heap Analysis Tool

Starting 'jhat' Web Server on a Heap Dump File

Listing Instance Counts of All Classes

Browsing Object Instance Values

Object Query Language (OQL)

Searching for Instances with OQL Statements

Dr. Herong Yang, updated in 2008
Changing HotSpot VM Option using 'jinfo'