Getting the parameters of a running JVM(获取正在运行的 JVM 的参数)
问题描述
有没有办法获取正在运行的JVM的参数?
Is there a way to get the parameters of a running JVM?
是否有像 jstat 这样的命令行工具,它将 PID 作为输入JVM 并返回其起始参数?我对启动 JVM 时给出的 -Xmx 和 -Xms 值特别感兴趣.
Is there a command-line tool, like jstat, which takes as input the PID of the JVM and returns its starting parameters? I am particularly interested in the -Xmx and -Xms values that were given when starting the JVM.
为了澄清我对 JVM 的限制,我们想检查它是否在生产服务器上运行.这就是为什么我们更喜欢最小的干扰.我们能够使用 jstat 监控 JVM,因此我们希望有一个类似的简单解决方案来访问参数.
To clarify my constraints for the JVM, we would like to check if it is running on a production server. That's why we prefer the minimum disruption. We are able to monitor the JVM using jstat, and so we hope there's a similar simple solution to access the parameters.
我们还尝试使用 jvisualvm 获取参数.但是为了连接到远程 jvm,我们需要运行 jstatd 并修改 JVM 的安全设置,我们发现这在生产服务器上非常具有破坏性和风险.
We also tried to get the parameters using jvisualvm. But in order to connect to a remote jvm, we need to run jstatd and modify the security settings of the JVM, which we found to be very disruptive and risky on a production server.
推荐答案
你可以像这样使用jps:
You can use jps like:
jps -lvm
它会打印如下内容:
4050 com.intellij.idea.Main -Xms128m -Xmx512m -XX:MaxPermSize=250m -ea -Xbootclasspath/a:../lib/boot.jar -Djb.restart.code=88
4667 sun.tools.jps.Jps -lvm -Dapplication.home=/opt/java/jdk1.6.0_22 -Xms8m
这篇关于获取正在运行的 JVM 的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取正在运行的 JVM 的参数


- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01