FULL PRODUCT VERSION :
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Centos 6.5
Linux whistler 3.12.0-1.el6.elrepo.x86_64 #1 SMP Mon Nov 4 15:14:03 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The -XX:Metaspace setting to set the minimum metaspace size is ignored.
The problem is that when this setting is ignored, the algorithm to increase the metaspace sets in which can cause full garbage collections. This is undesirable for a production system so we want to set the minimum and maximum metaspace size equal. E.g.
java -XX:MaxMetaspaceSize=768m -XX:MetaspaceSize=768m X
This way we hope to get the same behavior back as we had with the permgen space in java <= 7.
Also jvisualvm is showing incorrect data.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the foillowing iava class (X.java)
Now run this class as follows:
java -XX:MaxMetaspaceSize=768m -XX:MetaspaceSize=768m X
In jvisualvm make sure that the mbeans plugin is installed.
Now open jvisualvm and click on Monitoring/Metaspace.
There the wrong metaspace size is shown. Also the size will be less than the maximum.
In jvisualvm nagivate to Mbeans/java.lang/MemoryPool/Metaspace
Now doubleclick on Usage. There you will find that max is set correctly to the value of 768m = 768*1024*1024 bytes. Also the minimum is set to 0.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Minimum and maximum values should be set equal in the jvisualvm mbeans.
Also the maximum should displayed in the monitoring/metaspace view should be set correctly and the size should be equal to the max.
ACTUAL -
jvisualvm/monitoring: wrong value for max and size < max.
jvisualvm/Metaspace mbean: correct value for minimum.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Full GCs can occur on production applications that create many classes at runtime, triggered by full GCs.
When garbase collection logging is enabled, the following entries are observed in the gc logs.
Full GC (Metadata GC Threshold)
i.e. Full garbage collections are triggered by metaspace collections.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class X {
public static void main(String[] args) throws Exception {
System.out.println("Sleeping indefinitely");
while (true) {
Thread.sleep(1000);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None.
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Centos 6.5
Linux whistler 3.12.0-1.el6.elrepo.x86_64 #1 SMP Mon Nov 4 15:14:03 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The -XX:Metaspace setting to set the minimum metaspace size is ignored.
The problem is that when this setting is ignored, the algorithm to increase the metaspace sets in which can cause full garbage collections. This is undesirable for a production system so we want to set the minimum and maximum metaspace size equal. E.g.
java -XX:MaxMetaspaceSize=768m -XX:MetaspaceSize=768m X
This way we hope to get the same behavior back as we had with the permgen space in java <= 7.
Also jvisualvm is showing incorrect data.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the foillowing iava class (X.java)
Now run this class as follows:
java -XX:MaxMetaspaceSize=768m -XX:MetaspaceSize=768m X
In jvisualvm make sure that the mbeans plugin is installed.
Now open jvisualvm and click on Monitoring/Metaspace.
There the wrong metaspace size is shown. Also the size will be less than the maximum.
In jvisualvm nagivate to Mbeans/java.lang/MemoryPool/Metaspace
Now doubleclick on Usage. There you will find that max is set correctly to the value of 768m = 768*1024*1024 bytes. Also the minimum is set to 0.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Minimum and maximum values should be set equal in the jvisualvm mbeans.
Also the maximum should displayed in the monitoring/metaspace view should be set correctly and the size should be equal to the max.
ACTUAL -
jvisualvm/monitoring: wrong value for max and size < max.
jvisualvm/Metaspace mbean: correct value for minimum.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Full GCs can occur on production applications that create many classes at runtime, triggered by full GCs.
When garbase collection logging is enabled, the following entries are observed in the gc logs.
Full GC (Metadata GC Threshold)
i.e. Full garbage collections are triggered by metaspace collections.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class X {
public static void main(String[] args) throws Exception {
System.out.println("Sleeping indefinitely");
while (true) {
Thread.sleep(1000);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None.