I'm running my java application under java 8 and I'm noticing a strange behaviour in my gc log file:
Java HotSpot(TM) 64-Bit Server VM (25.131-b11) for linux-amd64 JRE (1.8.0_131-b11), built on Mar 15 2017 01:23:40 by "java_re" with gcc 4.3.0 20080428 (Red Hat 4.3.0-8)
Memory: 4k page, physical 131855880k(737780k free), swap 8388604k(8192864k free)
CommandLine flags: -XX:InitialHeapSize=1073741824 -XX:MaxHeapSize=21474836480 -XX:MaxMetaspaceSize=1073741824 -XX:MaxNewSize=2147483648 -XX:+PrintGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCCause -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintPromotionFailure -XX:+PrintReferenceGC -XX:+PrintTLAB -XX:+PrintTenuringDistribution -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC
...
2019-04-15T02:15:29.588+0200: 12.457: [Full GC (Metadata GC Threshold) 2019-04-15T02:15:29.599+0200: 12.467: [SoftReference, 0 refs, 0.0000372 secs]2019-04-15T02:15:29.599+0200: 12.467: [WeakReference, 264 refs, 0.0000308 secs]2019-04-15T02:15:29.599+0200: 12.467: [FinalReference, 556 refs, 0.0000449 secs]2019-04-15T02:15:29.599+0200: 12.468: [PhantomReference, 0 refs, 1 refs, 0.0000053 secs]2019-04-15T02:15:29.599+0200: 12.468: [JNI Weak Reference, 0.0000087 secs][PSYoungGen: 98556K->0K(1908224K)] [ParOldGen: 189998K->108966K(699392K)] 288554K->108966K(2607616K), [Metaspace: 20670K->20670K(1069056K)], 0.0491849 secs] [Times: user=0.25 sys=0.04, real=0.05 secs]
...
2019-04-18T01:45:00.974+0200: 257383.843: [Full GC (Metadata GC Threshold) 2019-04-18T01:45:01.468+0200: 257384.337: [SoftReference, 253 refs, 0.0000833 secs]2019-04-18T01:45:01.468+0200: 257384.337: [WeakReference, 757380 refs, 0.1353332 secs]2019-04-18T01:45:01.604+0200: 257384.472: [FinalReference, 1164 refs, 0.0004652 secs]2019-04-18T01:45:01.604+0200: 257384.472: [PhantomReference, 1 refs, 48 refs, 0.0000144 secs]2019-04-18T01:45:01.604+0200: 257384.472: [JNI Weak Reference, 0.0000551 secs][PSYoungGen: 4573K->0K(333824K)] [ParOldGen: 5596982K->5594855K(8593920K)] 5601555K->5594855K(8927744K), [Metaspace: 799214K->799212K(1769472K)], 1.3237147 secs] [Times: user=6.77 sys=0.01, real=1.33 secs]
...
2019-04-18T02:10:00.972+0200: 258883.841: [Full GC (Metadata GC Threshold) 2019-04-18T02:10:01.466+0200: 258884.334: [SoftReference, 227 refs, 0.0000816 secs]2019-04-18T02:10:01.466+0200: 258884.334: [WeakReference, 747600 refs, 0.1386251 secs]2019-04-18T02:10:01.604+0200: 258884.473: [FinalReference, 829 refs, 0.0004398 secs]2019-04-18T02:10:01.605+0200: 258884.473: [PhantomReference, 1 refs, 50 refs, 0.0000148 secs]2019-04-18T02:10:01.605+0200: 258884.473: [JNI Weak Reference, 0.0000486 secs][PSYoungGen: 6331K->0K(334848K)] [ParOldGen: 5594855K->5597194K(9195520K)] 5601186K->5597194K(9530368K), [Metaspace: 799223K->799223K(1769472K)], 1.0449664 secs] [Times: user=6.36 sys=0.01, real=1.05 secs]
First, I see a lot of Full GC triggered with a small delay because of Metadata GC Threshold but the log doesn't explain why this full GC is triggered as the metadata size is still small. Also, in the last Full GC I have attached,I see Metaspace: 799223K->799223K(1769472K), but where did 1769472K came ?it is greater than the MaxMetaspaceSize being set ?