我有一个在Linux 64上的Tomcat 9.0.6中运行的Spring应用程序。由于它需要大量内存,因此我想尝试OpenJ9 JVM,该功能在这方面可能更有效(使用Hotspot的当前堆限制:- Xmx128G)。我安装了64位采用openjdk-8-jdk-openj9:
/usr/lib/jvm/adoptopenjdk-8-jdk-openj9/bin/java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
Eclipse OpenJ9 VM (build openj9-0.14.2, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20190521_315 (JIT enabled, AOT enable
OpenJ9 - 4b1df46fe
OMR - b56045d2
JCL - a8c217d402 based on jdk8u212-b04)
启动tomcat会导致以下错误:
This JVM package only includes the '-Xcompressedrefs' configuration. Please run the VM without specifying the '-Xnocompressedrefs' option or by specifying the '-Xcompressedrefs' option.
设置此选项后,出现以下错误:
JVMJ9GC028E Option too large: '-Xmx'
JVMJ9VM015W Initialization error for library j9gc29(2): Failed to initialize
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
文档尚不清楚,但是我发现了这一点:https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.vm.80.doc/docs/mm_gc_compressed_refs.html
Compressed references are used by default on a 64-bit IBM SDK when the value of -Xmx, which sets the maximum Java heap size, is in the correct range. Start of changes for service refresh 2 fix pack 10On AIX®, Linux and Windows systems, the default range is 0 - 57 GB. For larger heap sizes, you can try to use compressed references by explicitly setting -Xcompressedrefs.End of changes for service refresh 2 fix pack 10 However, larger heap sizes might result in an out of memory condition at run time because the VM requires some memory at low addresses. You might be able to resolve an out of memory condition in low addresses by using the -Xmcrs option.
因此,至少,此JDK构建至少支持压缩引用,并且要使用它,我必须手动设置它,因为我的Xmx超出了默认启用的范围,但是由于我的操作系统已经分配,因此失败小于4GB的内存范围,但是使用压缩引用需要一些内存。由于我永远不能保证不会出现这种情况,因此有没有办法可以在没有CompressedRefs的情况下使用OpenJ9?在内存消耗方面,这是否还会带来好处?还是有什么方法可以使用Xmx设置很高的Compressedrefs?
我也尝试设置此选项,但没有帮助:https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/openj9/xmcrs/index.html?view=embed
如何找到正确的尺寸? 1G和64m失败。即使我找到正确的设置,该值也将如何保证OS尚未分配所有较低的内存地址?
我发现此版本允许使用非压缩引用,从而解决了我的问题:https://adoptopenjdk.net/releases.html?variant=openjdk8&jvmVariant=openj9#linuxxl
您能否使用设置'-XX:MaxRAMPercentage = N'?