Details
-
Bug
-
Resolution: Fixed
-
P3
-
8-pool, 11-pool, 15-pool, 16
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8262251 | 16.0.2 | Harold Seigel | P3 | Resolved | Fixed | b01 |
JDK-8262131 | 16.0.1 | Harold Seigel | P3 | Resolved | Fixed | b06 |
JDK-8266630 | 15.0.4 | Yuri Nesterenko | P3 | Resolved | Fixed | b02 |
JDK-8261612 | 11.0.12-oracle | Dukebot | P3 | Resolved | Fixed | b01 |
JDK-8261497 | 11.0.11 | David Holmes | P3 | Resolved | Fixed | b03 |
JDK-8261793 | openjdk8u292 | Alexandr Scherbatiy | P3 | Resolved | Fixed | b04 |
Description
macOS 10.14.6
$ java -version
openjdk version "16-ea" 2021-03-16
OpenJDK Runtime Environment (build 16-ea+32-2190)
OpenJDK 64-Bit Server VM (build 16-ea+32-2190, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When setting the Metaspace max option -XX:MaxMetaspaceSize=256m via the JAVA_TOOL_OPTIONS environment variable, the Metaspace max is not programmatically retrievable from the MemoryPoolMXBean for the Metaspace. However, the MaxMetaspaceSize does appear to be configured according to the output produced by the option -XX:+PrintFlagsFinal which contains:
size_t MaxMetaspaceSize = 268435456 {product} {environment}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See the provided source code which corresponds to the referenced MetaspaceMaxMain.java file below. The following command (on OSX, at least) reproduces the issue.
JAVA_TOOL_OPTIONS="-XX:MaxMetaspaceSize=256m" java MetaspaceMaxMain.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Picked up JAVA_TOOL_OPTIONS: -XX:MaxMetaspaceSize=256m
Metaspace pool max: 268435456
ACTUAL -
Picked up JAVA_TOOL_OPTIONS: -XX:MaxMetaspaceSize=256m
Metaspace pool max: -1
---------- BEGIN SOURCE ----------
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;
public class MetaspaceMaxMain {
public static void main(String[] args) {
MemoryPoolMXBean metaspaceMemoryPool = ManagementFactory.getPlatformMXBeans(MemoryPoolMXBean.class)
.stream()
.filter(pool -> "Metaspace".equals(pool.getName()))
.findFirst()
.orElseThrow();
System.out.println("Metaspace pool max: " + metaspaceMemoryPool.getUsage().getMax());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Using the JDK_JAVA_OPTIONS environment variable instead of JAVA_TOOL_OPTIONS has the expected behavior. Alternatively, setting the MaxMetaspaceSize on the command line works as expected.
Attachments
Issue Links
- backported by
-
JDK-8261497 Cannot programmatically retrieve Metaspace max set via JAVA_TOOL_OPTIONS
-
- Resolved
-
-
JDK-8261612 Cannot programmatically retrieve Metaspace max set via JAVA_TOOL_OPTIONS
-
- Resolved
-
-
JDK-8261793 Cannot programmatically retrieve Metaspace max set via JAVA_TOOL_OPTIONS
-
- Resolved
-
-
JDK-8262131 Cannot programmatically retrieve Metaspace max set via JAVA_TOOL_OPTIONS
-
- Resolved
-
-
JDK-8262251 Cannot programmatically retrieve Metaspace max set via JAVA_TOOL_OPTIONS
-
- Resolved
-
-
JDK-8266630 Cannot programmatically retrieve Metaspace max set via JAVA_TOOL_OPTIONS
-
- Resolved
-
- relates to
-
JDK-8013590 NPG: Add a memory pool MXBean for Metaspace
-
- Resolved
-
-
JDK-8217848 [Graal] vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted003/TestDescription.java fails
-
- Resolved
-
-
JDK-8261907 runtime\Metaspace\MaxMetaspaceSizeEnvVarTest.java fails on 11u
-
- Resolved
-
- links to
-
Commit openjdk/jdk15u-dev/f0f89d22
-
Commit openjdk/jdk16u/5828fc5b
-
Commit openjdk/jdk/b6a73673
-
Review openjdk/jdk15u-dev/44
-
Review openjdk/jdk16u/38
-
Review openjdk/jdk/2275