java 15: jinfo查看jvm配置参数和系统属性
一,jinfo查看帮助
[lhdop@blog ~]$ jinfo --help Usage: jinfo <option> <pid> (to connect to a running process) where <option> is one of: -flag <name> to print the value of the named VM flag -flag [+|-]<name> to enable or disable the named VM flag -flag <name>=<value> to set the named VM flag to the given value -flags to print VM flags -sysprops to print Java system properties <no option> to print both VM flags and system properties -? | -h | --help | -help to print this help message
说明:刘宏缔的架构森林是一个专注架构的博客,
网站:https://blog.imgtouch.com
本文: https://blog.imgtouch.com/index.php/2023/06/01/java-15-jinfo-zha-kan-jvm-pei-zhi-can-shu-he-xi-tong-shu/
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,jinfo的使用例子
1,打印vm全部的参数
[lhdop@blog ~]$ jinfo -flags 5426 VM Flags: -XX:CICompilerCount=3 -XX:ConcGCThreads=1 -XX:G1ConcRefinementThreads=4 -XX:G1HeapRegionSize=2097152 -XX:GCDrainStackTargetSize=64
-XX:InitialHeapSize=251658240 -XX:MarkStackSize=4194304 -XX:MaxHeapSize=4026531840 -XX:MaxNewSize=2415919104 -XX:MinHeapDeltaBytes=2097152
-XX:MinHeapSize=8388608 -XX:NonNMethodCodeHeapSize=5832780 -XX:NonProfiledCodeHeapSize=122912730 -XX:ProfiledCodeHeapSize=122912730
-XX:ReservedCodeCacheSize=251658240 -XX:+SegmentedCodeCache -XX:SoftMaxHeapSize=4026531840 -XX:+UseCompressedClassPointers
-XX:+UseCompressedOops -XX:+UseG1GC
2,输出当前 jvm 的全部系统属性
[lhdop@blog ~]$ jinfo -syspros 5426 Java System Properties: #Wed Mar 23 21:59:46 CST 2022 java.specification.version=15 sun.jnu.encoding=UTF-8 java.class.path=/data/store/back/jar/storeback-0.0.1-SNAPSHOT.jar java.vm.vendor=Oracle Corporation sun.arch.data.model=64 catalina.useNaming=false java.vendor.url=https\://java.oracle.com/ user.timezone=Asia/Shanghai os.name=Linux java.vm.specification.version=15 sun.java.launcher=SUN_STANDARD user.country=US sun.boot.library.path=/usr/local/soft/jdk-15/lib ...
3,打印单个vm参数:
[lhdop@blog ~]$ jinfo -flag PrintGC 5426
-XX:-PrintGC
说明:-表示false,+表示true
[lhdop@blog ~]$ jinfo -flag MinHeapSize 5426 -XX:MinHeapSize=8388608
4,得到支持动态修改的vm参数
[lhdop@blog ~]$ java -XX:+PrintFlagsInitial | grep manageable uintx G1PeriodicGCInterval = 0 {manageable} {default} double G1PeriodicGCSystemLoadThreshold = 0.000000 {manageable} {default} bool HeapDumpAfterFullGC = false {manageable} {default} bool HeapDumpBeforeFullGC = false {manageable} {default} bool HeapDumpOnOutOfMemoryError = false {manageable} {default} ccstr HeapDumpPath = {manageable} {default} uintx MaxHeapFreeRatio = 70 {manageable} {default} uintx MinHeapFreeRatio = 40 {manageable} {default} bool PrintClassHistogram = false {manageable} {default} bool PrintConcurrentLocks = false {manageable} {default} bool ShowCodeDetailsInExceptionMessages = true {manageable} {default} size_t SoftMaxHeapSize = 0 {manageable} {default}
其中标志为 manageable的参数,是可以用jinfo手动修改的,
可见只占一小部分,就不再演示了
三,查看java版本
[lhdop@blog tools]$ java --version java 15 2020-09-15 Java(TM) SE Runtime Environment (build 15+36-1562) Java HotSpot(TM) 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)