JVM default garbage collector literacy, those who say UseParallelGC is PS + Serial Old don't slap in the face

Opinion correction: 1.7 1.8 Default UseParallelGC = PS + PO

First look at the wrong example, pay attention! ! ! it's wrong! ! !

Originally, you wanted to rely on Baidu, but unexpectedly entered a pit. The blog address will not be posted. I hope that the landlords will remember to verify before posting, so as not to mislead.

Two wrong ways! ! !

c11904443b2627d049facad521f3e970.png

This picture CSDN sucks, and after trying for a long time, I can't upload it, so I won't post it.

Especially the blogger in the second picture, don't you think it's a slap in the face? ? ?

Better do it yourself

View the default garbage collector of the JVM

cmd命令: java -XX:+PrintCommandLineFlags -version

1. Set operating parameters

-Xmn5M
-Xms5M
-Xmx5M
-Xss5M
-XX:+PrintGCDetails
-XX:+PrintCommandLineFlags
-XX:+UseParallelGC

implement

List list = new ArrayList();
        for (int i = 0; i< 10; i++){
            list.add(new byte[1024]);
        }

result:

-XX:InitialHeapSize=5242880 -XX:MaxHeapSize=5242880 -XX:MaxNewSize=5242880 -XX:NewSize=5242880 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:ThreadStackSize=5120 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC 
[GC (Allocation Failure) [PSYoungGen: 4096K->507K(4608K)] 4096K->1201K(5632K), 0.0023635 secs] [Times: user=0.00 sys=0.01, real=0.00 secs] 
[Full GC (Ergonomics) [PSYoungGen: 507K->498K(4608K)] [ParOldGen: 693K->664K(1024K)] 1201K->1163K(5632K), [Metaspace: 2652K->2652K(1056768K)], 0.0034648 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[Full GC (Ergonomics) [PSYoungGen: 4594K->496K(4608K)] [ParOldGen: 664K->995K(1024K)] 5259K->1491K(5632K), [Metaspace: 2833K->2833K(1056768K)], 0.0046685 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
Heap
 PSYoungGen      total 4608K, used 1031K [0x00000000ffb00000, 0x0000000100000000, 0x0000000100000000)
  eden space 4096K, 25% used [0x00000000ffb00000,0x00000000ffc01dc0,0x00000000fff00000)
  from space 512K, 0% used [0x00000000fff00000,0x00000000fff00000,0x00000000fff80000)
  to   space 512K, 0% used [0x00000000fff80000,0x00000000fff80000,0x0000000100000000)
 ParOldGen       total 1024K, used 995K [0x00000000ffa00000, 0x00000000ffb00000, 0x00000000ffb00000)
  object space 1024K, 97% used [0x00000000ffa00000,0x00000000ffaf8c60,0x00000000ffb00000)
 Metaspace       used 3203K, capacity 4496K, committed 4864K, reserved 1056768K
  class space    used 343K, capacity 388K, committed 512K, reserved 1048576K

Process finished with exit code 0

Obvious: UseParallelGC = PS + PO

Setting: -XX:+UseSerialGC , it should be no Serial Old

Setting: -XX:+UseParNewGC only sees PN, the default Serial Old should be unplayed

[GC (Allocation Failure) [ParNew: 4096K->511K(4608K), 0.0022338 secs] 4096K->1201K(5632K), 0.0022637 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[GC (Allocation Failure) [ParNew: 4607K->4607K(4608K), 0.0000107 secs][Tenured: 690K->1023K(1024K), 0.0023365 secs] 5297K->1732K(5632K), [Metaspace: 2835K->2835K(1056768K)], 0.0023842 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
Heap
 par new generation   total 4608K, used 2309K [0x00000000ffa00000, 0x00000000fff00000, 0x00000000fff00000)
  eden space 4096K,  56% used [0x00000000ffa00000, 0x00000000ffc414e8, 0x00000000ffe00000)
  from space 512K,   0% used [0x00000000ffe80000, 0x00000000ffe80000, 0x00000000fff00000)
  to   space 512K,   0% used [0x00000000ffe00000, 0x00000000ffe00000, 0x00000000ffe80000)
 tenured generation   total 1024K, used 1023K [0x00000000fff00000, 0x0000000100000000, 0x0000000100000000)
   the space 1024K,  99% used [0x00000000fff00000, 0x00000000ffffffb0, 0x0000000100000000, 0x0000000100000000)
 Metaspace       used 3266K, capacity 4496K, committed 4864K, reserved 1056768K
  class space    used 350K, capacity 388K, committed 512K, reserved 1048576K

-XX:+UseConcMarkSweepGC see PN + cms in full

-XX:InitialHeapSize=5242880 -XX:MaxHeapSize=5242880 -XX:MaxNewSize=5242880 -XX:MaxTenuringThreshold=6 -XX:NewSize=5242880 -XX:OldPLABSize=16 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:ThreadStackSize=5120 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:-UseLargePagesIndividualAllocation -XX:+UseParNewGC 
[GC (Allocation Failure) [ParNew (promotion failed): 4096K->4608K(4608K), 0.0026160 secs][CMS: 498K->985K(1024K), 0.0022091 secs] 4096K->1167K(5632K), [Metaspace: 2652K->2652K(1056768K)], 0.0048715 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[Full GC (Allocation Failure) [CMS: 1023K->1023K(1024K), 0.0039718 secs] 5631K->1669K(5632K), [Metaspace: 3162K->3162K(1056768K)], 0.0040140 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[GC (CMS Initial Mark) [1 CMS-initial-mark: 1023K(1024K)] 1712K(5632K), 0.0006037 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.002/0.002 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[GC (CMS Final Remark) [YG occupancy: 1935 K (4608 K)][Rescan (parallel) , 0.0002704 secs][weak refs processing, 0.0000052 secs][class unloading, 0.0002659 secs][scrub symbol table, 0.0003359 secs][scrub string table, 0.0000815 secs][1 CMS-remark: 1023K(1024K)] 2958K(5632K), 0.0010050 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
Heap
 par new generation   total 4608K, used 1935K [0x00000000ffa00000, 0x00000000fff00000, 0x00000000fff00000)
  eden space 4096K,  47% used [0x00000000ffa00000, 0x00000000ffbe3df0, 0x00000000ffe00000)
  from space 512K,   0% used [0x00000000ffe80000, 0x00000000ffe80000, 0x00000000fff00000)
  to   space 512K,   0% used [0x00000000ffe00000, 0x00000000ffe00000, 0x00000000ffe80000)
 concurrent mark-sweep generation total 1024K, used 952K [0x00000000fff00000, 0x0000000100000000, 0x0000000100000000)
 Metaspace       used 3330K, capacity 4496K, committed 4864K, reserved 1056768K
  class space    used 353K, capacity 388K, committed 512K, reserved 1048576K

-XX:+UseParallelOldGC   PS + PO

-XX:InitialHeapSize=5242880 -XX:MaxHeapSize=5242880 -XX:MaxNewSize=5242880 -XX:NewSize=5242880 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:ThreadStackSize=5120 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelOldGC 
[GC (Allocation Failure) [PSYoungGen: 4096K->511K(4608K)] 4096K->1201K(5632K), 0.0009040 secs] [Times: user=0.06 sys=0.02, real=0.00 secs] 
[Full GC (Ergonomics) [PSYoungGen: 511K->502K(4608K)] [ParOldGen: 690K->661K(1024K)] 1201K->1163K(5632K), [Metaspace: 2652K->2652K(1056768K)], 0.0030615 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[Full GC (Ergonomics) [PSYoungGen: 4598K->500K(4608K)] [ParOldGen: 661K->991K(1024K)] 5259K->1492K(5632K), [Metaspace: 2836K->2836K(1056768K)], 0.0046431 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
Heap
 PSYoungGen      total 4608K, used 2180K [0x00000000ffb00000, 0x0000000100000000, 0x0000000100000000)
  eden space 4096K, 53% used [0x00000000ffb00000,0x00000000ffd21338,0x00000000fff00000)
  from space 512K, 0% used [0x00000000fff00000,0x00000000fff00000,0x00000000fff80000)
  to   space 512K, 0% used [0x00000000fff80000,0x00000000fff80000,0x0000000100000000)
 ParOldGen       total 1024K, used 991K [0x00000000ffa00000, 0x00000000ffb00000, 0x00000000ffb00000)
  object space 1024K, 96% used [0x00000000ffa00000,0x00000000ffaf7f30,0x00000000ffb00000)
 Metaspace       used 3204K, capacity 4496K, committed 4864K, reserved 1056768K
  class space    used 342K, capacity 388K, committed 512K, reserved 1048576K

-XX:+UseG1GC