Hi Roy, MaxMetaspaceSize is just a soft limit capping the maximum memory size committed metaspace can take.
In short it works like that (with UseCompressedClassPointers= true which is the default): Metaspace is divided into two parts, the "compressed class space" and the "non-class" metaspace. The former needs to be pre-reserved as a contiguous memory range, for technical reasons. By default that range is 1G (note, only reserved memory, not yet committed). The latter is allocated on demand. Basically, this is a chain of memory mappings which grows as new metaspace is allocated. So it is tiny at start and will grow (add new mappings as needed). This means that for the non-class metaspace part, reserved and committed should be close together. That explains the total reserved size of 1073152K which is (1G + a little bit). In reality, outside of 32bit VMs, this number is not of much concern, the committed size is more important. When the metaspace grows and new memory is committed, at periodic intervals the VM will attempt a GC to clean up remnants of unreachable classes and free Metaspace. This is to prevent a too fast growth of Metaspace. By setting XX:MaxMetaspaceFreeRatio, you basically disable this mechanism. This means metaspace committed space will grow up to MaxMetaspaceSize (if that is given) and then do a GC. You can use jcmd <pid> VM.metaspace to look at the details. See also: https://stuefe.de/posts/metaspace/analyze-metaspace-with-jcmd/ Cheers, Thomas On Thu, Oct 17, 2019 at 8:16 AM Roy Zhang <roy.sunny.zhang...@gmail.com> wrote: > Dear JVM experts, > > Regarding to > https://gist.github.com/erikdw/e730a1249887bb4462f226658351cfa4, we can > set -XX:MinMetaspaceFreeRatio=0 & -XX:MaxMetaspaceFreeRatio=100 to disable > dynamic resize metaSpace (changing high-water mark) which could trigger > full gc. But when i set the following metaspace related java > opts(MetaspaceSize and MaxMetaspacesize is 2g), reserved MetaspaceSize is > still 1G which is same as the default behavior(didn't set any metaSpace > related java opts, MetaspaceSize is ~20M). > Could u please kindly provide help? Thx in advance! > > jcmd 15958 GC.heap_info > 15958: > garbage-first heap total 10485760K, used 2490178K [0x0000000540000000, > 0x0000000540405000, 0x00000007c0000000) > region size 4096K, 552 young (2260992K), 0 survivors (0K) > * Metaspace used 25746K, capacity 26634K, committed 26752K, reserved > 1073152K* > class space used 2227K, capacity 2358K, committed 2432K, reserved > 1048576K > > *Metaspace java opts:* > -XX:MetaspaceSize=2g > -XX:MaxMetaspaceSize=2g > -XX:MinMetaspaceFreeRatio=0 > -XX:MaxMetaspaceFreeRatio=100 > > *JVM version*: > openjdk version "1.8.0_201" > OpenJDK Runtime Environment (build 1.8.0_201-b09) > OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode) > > *Linux version:* > 4.14.123-111.109.amzn2.x86_64 > > Thanks, > Roy > _______________________________________________ > hotspot-gc-use mailing list > hotspot-gc-use@openjdk.java.net > https://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use >
_______________________________________________ hotspot-gc-use mailing list hotspot-gc-use@openjdk.java.net https://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use