英文:
JVisualVM indicates -Xmx is being ignored when passed inline
问题
查阅了许多类似问题,有些问题完全不同,或者没有提供解释。
以下是应用程序的执行方式。使用大小为1234M以确保不会选择任何默认值。还验证了没有设置与Java相关的环境变量。
> java -Xms512M -Xmx1234M -jar myApp.jar
应用程序加载时,JVisualVM显示如下,根据JVM参数,-Xmx是可见的。
在“监视”选项卡下,检查了图形视图,显示最大堆大小为8G。
如果运行多个应用程序,可能会有问题。作为测试,设置了环境变量_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.
Under the Monitor tab, the graphical view is inspected and this shows a max heap size of 8G.
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 :
Under the Monitor tab, the graphical view is inspected and this shows the value from the environment variable.
Why does java not pickup the values passed in via the command line?
专注分享java语言的经验与见解,让所有开发者获益!
评论