当前位置:网站首页>Jinfo of JVM command: view and modify JVM configuration parameters in real time

Jinfo of JVM command: view and modify JVM configuration parameters in real time

2022-07-07 06:00:00 Zhang Junjie 1994

Study Silicon Valley Song Hongkang JVM From entry to mastery Learning notes of

summary

jinfo All in all Configuration Info for Java
The function is to view the virtual machine configuration parameter information , It can also be used to adjust the configuration parameters of virtual machines .
In many cases ,Java The application does not specify all Java Virtual machine parameters , After all, there are too many virtual machine parameters , Developers may not know something Java What is the default value of virtual machine parameter settings , For example, I would like to see the default ratio of the new generation to the old generation . At this time, if developers look for development documents , It may be more troublesome , But use jinfo Tools , Developers can quickly view the parameters of a virtual machine configuration .

image.png

Basic grammar

image.png

see
jinfo -sysprops process id
Can view by System.getProperties() Parameters obtained
jinfo -flags process id
Look at some parameters that have been assigned values
jinfo -flag Parameter name process id
View a certain java Process specific parameter information

modify
image.png
image.png
in the light of boolean type
jinfo -flag [+|-] Parameter name process id
For non boolean type
jinfo -flag Parameter name = Parameter values process id

demonstration

image.png
image.png

After setting, start the above main Method . Now use the command to check .
image.png
use jps -v You can see the parameters we set ourselves , But if we want to know how many parameters we haven't set , We use jps -v Not very good .


Use jinfo -sysprops 2540 You can check some information .
image.png


Query the information assigned value
image.png


Check the specific assigned information , Query whether to use parallel garbage collector . “+” Representative used
image.png

Query whether a serial garbage collector is used , “- ” The representative did not use
image.png


Check the maximum heap space
image.png


Modifying parameters can take effect immediately , But not all values can be dynamically modified , Only those marked as manageable Of flag It can be modified in real time ,

The following command is to view PrintGCDetails Value , The result is “-” The representative has not modified
image.png

The first line of command PrintGCDetails Add “+” , Then execute the command in the second line , see , I found out that it was "-“, Now it's ”+", Description parameters have been modified .
image.png

The following is also dynamic modification , Check... After modification , It was found that the modification was successful .

image.png

Be careful , Dynamically modified values are only temporarily valid , When you shut down this process , This dynamically modified parameter is invalid , Next time you start Java When it comes to programming , Back to the original value .

Expand

expand
java -XX:+PrintFlagsInitial
View all JVM Initial value of parameter start
java -XX:+PrintFlagsFinal
View all JVM The final value of the parameter
image.png
Add a colon before the value : Is the modified value , What is not added is the initial value that has not changed

java - Parameter name :+PrintCommandLineFlags
Look at those that have been used by users or JVM Set up detailed XX The name and value of the parameter

demonstration

image.png
Output the result to 1.txt Inside .

image.png

原网站

版权声明
本文为[Zhang Junjie 1994]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070046516994.html