Don't use VM.maxDirectMemory() on IBM J9 / Eclipse OpenJ9 to retrieve direct memory limit (#7966)
Motivation: On J9 / OpenJ9 netty initializes this value with 64M, even the direct accessible memory is actually unbounded. Modifications: Skip usage of VM.maxDirectMemory() on J9 / OpenJ9 Result: More correct direct memory limit detection. Fixes #7654.
This commit is contained in:
parent
c3637ff42c
commit
8a85761500
@ -993,10 +993,14 @@ public final class PlatformDependent {
|
|||||||
try {
|
try {
|
||||||
systemClassLoader = getSystemClassLoader();
|
systemClassLoader = getSystemClassLoader();
|
||||||
|
|
||||||
// On z/OS we should not use VM.maxDirectMemory() as it not reflects the correct value.
|
// When using IBM J9 / Eclipse OpenJ9 we should not use VM.maxDirectMemory() as it not reflects the
|
||||||
|
// correct value.
|
||||||
// See:
|
// See:
|
||||||
// - https://github.com/netty/netty/issues/7654
|
// - https://github.com/netty/netty/issues/7654
|
||||||
if (!SystemPropertyUtil.get("os.name", "").toLowerCase().contains("z/os")) {
|
String vmName = SystemPropertyUtil.get("java.vm.name", "").toLowerCase();
|
||||||
|
if (!vmName.startsWith("ibm j9") &&
|
||||||
|
// https://github.com/eclipse/openj9/blob/openj9-0.8.0/runtime/include/vendor_version.h#L53
|
||||||
|
!vmName.startsWith("eclipse openj9")) {
|
||||||
// Try to get from sun.misc.VM.maxDirectMemory() which should be most accurate.
|
// Try to get from sun.misc.VM.maxDirectMemory() which should be most accurate.
|
||||||
Class<?> vmClass = Class.forName("sun.misc.VM", true, systemClassLoader);
|
Class<?> vmClass = Class.forName("sun.misc.VM", true, systemClassLoader);
|
||||||
Method m = vmClass.getDeclaredMethod("maxDirectMemory");
|
Method m = vmClass.getDeclaredMethod("maxDirectMemory");
|
||||||
|
Loading…
Reference in New Issue
Block a user