如何检查正在运行的java应用程序配置的Xmx值
我正在创建一个 NSIS 脚本,其中可以在安装过程中设置正在安装的 java 应用程序的 Xmx 值。我不确定这个参数是否设置正确。有没有办法在应用程序运行时检查配置的 Xmx 值?
I'm creating an NSIS script, where the Xmx value for the java application being installed can be set during the installation process. I'm not sure if this parameter is being set correctly. Is there a way to check the configured Xmx value when the application is running?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
就我而言,jmap 是我能找到的最佳解决方案:
上面的命令显示完整的堆配置+当前使用情况。
jmap命令包含在jdk的bin目录下。
In my case, jmap is the best solution I could find:
The above command shows full heap configuration + current usage.
The jmap command is included inside the jdk in the bin directory.
便宜又脏(不确定可靠性):
还成功使用了以下方法:
Cheap and dirty (not sure on reliability):
Have also used the following with success:
jps
是一个很好的解决方案,只需运行,记住以启动该进程的用户身份运行它,否则它将无法正常工作。
jps
is a good solution, just runremember to run it as the user that launched the process though, or it will not work properly.
Doron Gold 给出了 Java 8 及以下版本的正确答案。对于 Java 9 及更高版本,您可以通过使用获得相同的信息
Doron Gold gave the correct answer for Java 8 and below. For Java 9 and above you can get the same info by using
我是《kill -3》的忠实粉丝PID> ,它将为您提供有关当前内存和垃圾收集以及所有线程的堆栈的详细信息。
I'm a big fan of kill -3 < pid > , which will give you details on the current memory and garbage collections along with stacks for all threads.
以下内容适用于 JVM 版本 11.0.16(我已安装 OpenJDK 11),
它可能适用于您而不使用“sudo”。
在 sudo jhsdb jmap --heap --pid给我以下错误消息后,我必须执行此操作:
线程“主”sun.jvm.hotspot.types.WrongTypeException 中出现异常:地址类型没有合适的匹配项
The following worked for me for JVM version 11.0.16 (I had installed OpenJDK 11)
It may work for you without using "sudo".
I had to do this after
sudo jhsdb jmap --heap --pid <pid>
was giving me the following error message:Exception in thread "main" sun.jvm.hotspot.types.WrongTypeException: No suitable match for type of address