我用docker搭建了一个java程序,Dockerfile的开头是
FROM openjdk:8-jdk-alpine
但我注意到 jvm 命令 jinfo 没有 -flags
,这是怎么回事?
bash-4.4# ./jinfo
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
-h | -help to print this help message
最佳答案
Alpine 的 JDK 是在没有 Serviceability Agent 的情况下构建的支持,因为 SA 依赖于 musl does not have 的功能.
一些 JDK 实用程序在幕后使用可服务性代理来实现某些功能。 jinfo -flags
是此类实用程序的一个示例。其他也在后台使用 SA 的示例是 jmap -F
和 jstack -F
.这些选项在 Alpine JDK 中也不可用。
在 this answer我描述了强制模式 ( -F
) 与正常模式的区别,以及可服务性代理在其中扮演的角色。
jinfo -flags
可以替换为jcmd <pid> VM.flags
.
jcmd
不依赖 SA,适用于 Alpine Linux。
关于java - 为什么 jvm 命令 `jinfo` 在 alpine openjdk8 发行版中没有 `-flags`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60629930/