JDK's built-in tool jinfo and jdk's built-in jinfo
Jinfo is a built-in Java Configuration tool for JDK. In the bin directory of java, jinfo is used to view and adjust the parameters of the Virtual Machine in real time. Although the-v parameters of the Jps command can be used to view the list of specified parameters displayed when the virtual machine is started. However, if you want to know the default system value that has not been explicitly stated, you need to use jinfo.
Jinfo can also modify some virtual machine parameters that can be adjusted during running.
1. Jinfo Command Format
Jinfo [option] pid
2. Common Parameters
Usage:
Jinfo <option> <pid>
(To connect to a running process)
Where <option> is one:
-Flag <name> to print the value of the named VMflag
-Flag [+ |-] <name> to enable or disable the named VM flag
-Flag <name >=< value> to set thenamed VM flag to the given value
-H |-help to print this help message
3. Source Code
Package com. jdkTools;
Import java. util. ArrayList;
Import java. util. Random;
/**
* Simple applications have a large number of loops and creation objects for testing the jinfo of JDK.
* Parameter:-Xms30m-Xmx60m
*
* @ Author fan fangming
*/
Public class EasyJinfo {
Public byte [] placeHolder = newbyte [1*1024]; // placeHolder
Public static void main (String [] args) throws Exception {
While (true ){
Random random = newRandom ();
Int loops = random. nextInt (10000 );
EasyJinfo jstat = newEasyJinfo ();
System. out. println ("... building object:" + loops + "(items )");
Jstat. getLoop (loops); // multiple loops generate a large number of objects
Thread. sleep (100 );
}
}
Public void getLoop (int size ){
ArrayList <EasyJinfo> list = new ArrayList <EasyJinfo> ();
For (int I = 0; I <size; I ++ ){
EasyJinfo jstat = newEasyJinfo ();
List. add (jstat );
}
}
}
4. Running Parameters
* Parameter:-Xms30m-Xmx60m. this parameter is used to start a jvm vm.
5. Run the result (view and adjust JVM parameters in jinfo)
First, use JPS to find the corresponding process ID
C: \ Program Files \ Java \ jdk1.6.0 _ 25 \ bin> jps-v
5340 Jps-Dapplication. home = C: \ ProgramFiles \ Java \ jdk1.6.0 _ 25-Xms8m
1768 EasyJinfo-Xms30m-Xmx60m-Dfile. encoding = GBK
2856-Xms256m-Xmx768m-XX: MaxPermSize = 256 m-XX: ReservedCodeCacheSize = 64m-Dosgi.nls.warnings = ignore
Then run jinfo
C: \ Program Files \ Java \ jdk1.6.0 _ 25 \ bin> jinfo-flag1_vorratio 1768
-XX: Required vorratio = 8
Note: Many running parameters cannot be adjusted. If such exceptions occur, they cannot be adjusted:
Exception in thread "main" java. io. IOException: Command failed in target VM