【jvm】jinfo使用

时间:2024-03-22 12:08:56

jinfo介绍

jinfo 是一个命令行工具,用于查看和修改 Java 虚拟机(JVM)的配置参数。它通常用于调试和性能调优。

使用 jinfo 命令,你可以查看当前 JVM 的配置参数,包括堆大小、线程数、垃圾回收器类型等。此外,你还可以使用 jinfo 命令来修改 JVM 的配置参数,例如增加堆大小、更改垃圾回收器类型等。

 jinfo 命令通常与 jps 和 jstack 等其他 JVM 调试工具一起使用,以帮助你更好地理解和优化 Java 应用程序的性能。

语法

jinfo [option] pid

参数介绍

输入命令:jinfo -h

  • -flag name:查询某个标志(Flag)是否启用或其值。
  • -flag [+|-]name:启用或禁用某个标志(仅限支持动态更改的标志)。
  • -flags:显示所有标志及其值。
  • -sysprops:显示Java系统属性。

常用命令

jinfo  <pid>

查询某个标志(Flag)是否启用或其值
jinfo -flag <FlagName> <pid>
示例:

查询Java进程(pid为7813)是否启用了UseConcMarkSweepGC垃圾收集器:

jinfo -flag UseConcMarkSweepGC 7813

动态修改支持的标志

如果该标志支持运行时修改的话

jinfo -flag [+|-]<FlagName> <pid>
示例1:

启用Java进程(pid为7813)的PrintGCDetails选项以输出详细的GC日志:

jinfo -flag +PrintGCDetails 7813

示例2:

禁用Java进程(pid为7813)的PrintGCDetails选项以输出详细的GC日志:

jinfo -flag -PrintGCDetails 7813

 显示所有标志及其值
jinfo -flags  <pid>

  显示Java系统属性
jinfo -sysprops  <pid>


附件:jinfo返回信息

Attaching to process ID 4200, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.321-b07
Java System Properties:

java.vendor = Oracle Corporation
spring.sleuth.sampler.percentage = 1.0
sun.java.launcher = SUN_STANDARD
service.version = 2.5.0.RELEASE
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
sun.nio.ch.bugLevel = 
os.name = Linux
sun.boot.class.path = /usr/local/java/jdk1.8.0_321/jre/lib/resources.jar:/usr/local/java/jdk1.8.0_321/jre/lib/rt.jar:/usr/local/java/jdk1.8.0_321/jre/lib/sunrsasign.jar:/usr/local/java/jdk1.8.0_321/jre/lib/jsse.jar:/usr/local/java/jdk1.8.0_321/jre/lib/jce.jar:/usr/local/java/jdk1.8.0_321/jre/lib/charsets.jar:/usr/local/java/jdk1.8.0_321/jre/lib/jfr.jar:/usr/local/java/jdk1.8.0_321/jre/classes
yang.env = test2
java.vm.specification.vendor = Oracle Corporation
java.runtime.version = 1.8.0_321-b07
user.name = root
yang.dev-mode = true
user.language = zh
sun.boot.library.path = /usr/local/java/jdk1.8.0_321/jre/lib/amd64
info.version = 2.5.0.RELEASE
nacos.logging.path = /root/logs/nacos
info.desc = data-screen
PID = 4200
java.version = 1.8.0_321
user.timezone = Asia/Shanghai
spring.cloud.nacos.config.file-extension = yaml
sun.arch.data.model = 64
java.endorsed.dirs = /usr/local/java/jdk1.8.0_321/jre/lib/endorsed
sun.cpu.isalist = 
sun.jnu.encoding = UTF-8
file.encoding.pkg = sun.io
file.separator = /
java.specification.name = Java Platform API Specification
java.class.version = 52.0
csp.sentinel.api.port = 8719
user.country = CN
java.home = /usr/local/java/jdk1.8.0_321/jre
spring.cloud.nacos.discovery.server-addr = nacos.jl.com:8848
spring.cloud.alibaba.seata.tx-service-group = data-screen-group
java.vm.info = mixed mode
os.version = 3.10.0-1160.el7.x86_64
path.separator = :
java.vm.version = 25.321-b07
http.maxRedirects = 5
java.protocol.handler.pkgs = org.springframework.boot.loader
spring.cloud.nacos.config.server-addr = nacos.yang.com:8848
java.awt.printerjob = sun.print.PSPrinterJob
spring.cloud.nacos.discovery.namespace = 
sun.io.unicode.encoding = UnicodeLittle
awt.toolkit = sun.awt.X11.XToolkit
user.home = /root
yang.name = data-screen
java.specification.vendor = Oracle Corporation
java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
java.vendor.url = http://java.oracle.com/
spring.beaninfo.ignore = true
logging.config = classpath:log/logback-test2.xml
java.vm.vendor = Oracle Corporation
java.runtime.name = Java(TM) SE Runtime Environment
sun.java.command = data-screen.jar --spring.profiles.active=test2
java.class.path = data-screen.jar
project.name = data-screen
yang.is-local = false
java.vm.specification.name = Java Virtual Machine Specification
spring.cloud.nacos.config.shared-dataids = yang.yaml,test2.yaml
java.vm.specification.version = 1.8
sun.cpu.endian = little
sun.os.patch.level = unknown
java.awt.headless = true
java.io.tmpdir = /tmp
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
spring.main.allow-bean-definition-overriding = true
os.arch = amd64
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.ext.dirs = /usr/local/java/jdk1.8.0_321/jre/lib/ext:/usr/java/packages/lib/ext
@appId = data-screen
user.dir = /workspace/java/screen
spring.application.name = data-screen
spring.profiles.active = test2
line.separator = 

java.vm.name = Java HotSpot(TM) 64-Bit Server VM
file.encoding = UTF-8
csp.sentinel.charset = UTF-8
csp.sentinel.flow.cold.factor = 3
java.specification.version = 1.8

VM Flags:
Non-default VM flags: -XX:CICompilerCount=3 -XX:InitialHeapSize=130023424 -XX:MaxHeapSize=2051014656 -XX:MaxNewSize=683671552 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=42991616 -XX:OldSize=87031808 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:+UseParallelGC 
Command line: