JVisualVM显示在内联传递时忽略了-Xmx。

huangapple 未分类评论46阅读模式
英文:

JVisualVM indicates -Xmx is being ignored when passed inline

问题

查阅了许多类似问题,有些问题完全不同,或者没有提供解释。

以下是应用程序的执行方式。使用大小为1234M以确保不会选择任何默认值。还验证了没有设置与Java相关的环境变量。

> java -Xms512M -Xmx1234M -jar myApp.jar

应用程序加载时,JVisualVM显示如下,根据JVM参数,-Xmx是可见的。

-Xmx1234M在这里可见

在“监视”选项卡下,检查了图形视图,显示最大堆大小为8G。

8GB的堆

如果运行多个应用程序,可能会有问题。作为测试,设置了环境变量_JAVA_OPTIONS=-Xms1024m -Xmx2222m。使用值2222来验证不会选择任何默认值。

再次,JVisualVM显示传入的正确大小:

第二个测试

在“监视”选项卡下,检查了图形视图,显示来自环境变量的值。

正确的值在这里。

为什么Java不会使用通过命令行传递的值?

英文:

Read through a number of similar issues and some were completely different or didn't provide an explanation.

Here is how the application is executed. A size of 1234M is used to ensure no default value is being picked up. Also verified no Java related Environment Variables are set.

> java -Xms512M -Xmx1234M -jar myApp.jar

When the application loads, JVisualVM shows the following and based on the JVM Arguments the -Xmx is visble.

JVisualVM显示在内联传递时忽略了-Xmx。

Under the Monitor tab, the graphical view is inspected and this shows a max heap size of 8G.

JVisualVM显示在内联传递时忽略了-Xmx。

If multiple applications are running, this could be problematic.
As a test, the _JAVA_OPTIONS=-Xms1024m -Xmx2222m environment variable is set. The value 2222 is used to help verify no default value gets picked up.

Once again JVisualVM shows the proper size passed in :

JVisualVM显示在内联传递时忽略了-Xmx。

Under the Monitor tab, the graphical view is inspected and this shows the value from the environment variable.

JVisualVM显示在内联传递时忽略了-Xmx。

Why does java not pickup the values passed in via the command line?

huangapple
  • 本文由 发表于 2020年4月8日 22:30:30
  • 转载请务必保留本文链接:https://java.coder-hub.com/61103187.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定