获取正在运行的JVM的参数 [英] Getting the parameters of a running JVM

查看:151
本文介绍了获取正在运行的JVM的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法获取正在运行的JVM的参数?是否有像jstat这样的命令行工具,它将JVM的pid作为输入并返回其起始参数?我对启动JVM时给出的-Xmx和-Xms值特别感兴趣。谢谢。

Is there a way to get the parameters of a running JVM? 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. Thank you.

编辑:澄清我的约束。我们要检查的JVM正在生产服务器上运行。这就是为什么,我们更喜欢最小的破坏。我们可以使用jstat监控JVM,因此我们希望有一个类似的简单解决方案来访问参数。

Edit: To clarify my constraints. The JVM we would like to check 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的安全设置,我们发现它在生产服务器上非常具有破坏性和风险。

Edit: 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,如

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的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆