当前位置:网站首页>JVM foundation - > What garbage collectors does the JVM have?

JVM foundation - > What garbage collectors does the JVM have?

2022-06-12 22:09:00 Ouhuang xiaodezi

JVM What garbage collectors are there ?

The first stage : Serial ( Serial ) The collector -> Time in JDK1.3 about

  • new ⽣ generation (Serial— Mark - Copy algorithm ) ⽼ years (SerialOld— Mark - Sorting algorithm ) -> The opening configuration is as follows ↓

    -XX:+UseSerialGC
    

The second stage : Parallel ( parallel ) The collector -> JDK 6 Only then did China begin to offer ,JDK 8 By default

  • Parallel Collector is also called throughput collector , Use multithreading to clean up garbage

  • new ⽣ generation (Parallel— Mark - Copy algorithm ) ⽼ years (ParallelOld— Mark - Sorting algorithm ) -> The opening configuration is as follows ↓

    -XX:+UseParallelGC -XX:+UseParallelOldGC
    

The third stage : CMS( Concurrent ) The collector -> JDK 5 appear ,JDK 9 Has been abolished CMS Garbage collector

  • CMS The collector Minor( The younger generation ) GC Time meeting Pause all application threads , And in a multi-threaded way for garbage collection .

  • In the old age GC when No longer pause the application thread , Instead, several background threads are used to scan the space of the elderly on a regular basis , Recycle the objects that are no longer used in time .

  • new ⽣ generation (ParNew— Mark - Copy algorithm ) ⽼ years (ConcMarkSweep— Mark - Clear algorithm ) -> The opening configuration is as follows ↓

    -XX:+UseParNewGC -XX:+UseConcMarkSweepGC
    

The fourth stage : G1( Concurrent ) The collector -> JDK 8 Then widely used ,JDK 9 The default with G1 The collector

  • G1 The collector ( Or garbage priority collector ) The original intention of the design is to Try to shorten Handle Super pile ( Greater than 4GB) A pause when .

  • be relative to CMS In terms of the advantages of Reduce memory fragmentation .

  • Mark - Copy algorithm + Mark - Sorting algorithm -> The opening configuration is as follows ↓

    -XX:+UseG1GC
    

Be careful :

  • parallel GC: Multiple garbage collection threads operate simultaneously

  • Concurrent GC: Garbage collection threads work with user threads

  • Serial GC: A garbage collection thread

give the thumbs-up , handsome young man !!!

原网站

版权声明
本文为[Ouhuang xiaodezi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202281151361686.html