Difference between -XX:+UseParallelGC and -XX:+UseParNewGC

后端 未结 4 1441
悲&欢浪女
悲&欢浪女 2020-12-22 15:27

They are algorithms for the young generation garbage collection.

The second one (UseParNewGC) gets activated automatically with the concurrent tenured generation ga

4条回答
  •  时光取名叫无心
    2020-12-22 15:46

    Parallel GC

    • XX:+UseParallelGC Use parallel garbage collection for scavenges. (Introduced in 1.4.1)
    • XX:+UseParallelOldGC Use parallel garbage collection for the full collections. Enabling this option automatically sets -XX:+UseParallelGC. (Introduced in 5.0 update 6.)

    UseParNewGC

    UseParNewGC A parallel version of the young generation copying collector is used with the concurrent collector (i.e. if -XX:+ UseConcMarkSweepGC is used on the command line then the flag UseParNewGC is also set to true if it is not otherwise explicitly set on the command line).

    Perhaps the easiest way to understand was combinations of garbage collection algorithms made by Alexey Ragozin

    Young collector Old collector JVM option
    Serial (DefNew) Serial Mark-Sweep-Compact -XX:+UseSerialGC
    Parallel scavenge (PSYoungGen) Serial Mark-Sweep-Compact (PSOldGen) -XX:+UseParallelGC
    Parallel scavenge (PSYoungGen) Parallel Mark-Sweep-Compact (ParOldGen) -XX:+UseParallelOldGC
    Serial (DefNew) Concurrent Mark Sweep

    -XX:+UseConcMarkSweepGC

    -XX:-UseParNewGC

    Parallel (ParNew) Concurrent Mark Sweep

    -XX:+UseConcMarkSweepGC

    -XX:+UseParNewGC

    G1 -XX:+UseG1GC

    Conclusion:

    1. Apply -XX:+UseParallelGC when you require parallel collection method over YOUNG generation ONLY, (but still) use serial-mark-sweep method as OLD generation collection
    2. Apply -XX:+UseParallelOldGC when you require parallel collection method over YOUNG generation (automatically sets -XX:+UseParallelGC) AND OLD generation collection
    3. Apply -XX:+UseParNewGC & -XX:+UseConcMarkSweepGC when you require parallel collection method over YOUNG generation AND require CMS method as your collection over OLD generation memory
    4. You can't apply -XX:+UseParallelGC or -XX:+UseParallelOldGC with -XX:+UseConcMarkSweepGC simultaneously, that's why your require -XX:+UseParNewGC to be paired with CMS otherwise use -XX:+UseSerialGC explicitly OR -XX:-UseParNewGC if you wish to use serial method against young generation

提交回复
热议问题