Depth understanding JVM3 - Garbage Collector 1

Speaking before garbage collection algorithms is the methodology of memory recovery, now called the garbage collector is the realization of memory recovery. Java Virtual Machine specification has no provision for the realization of the garbage collector, so different manufacturers, different versions of the virtual machine provided by the garbage collectors are likely to vary considerably, and generally provide parameters for users according to their characteristics and applications requirements collector composition used through the ages.

6051634-766007f7e5b843fe.png
HotSpot VM garbage collector
  • Serial Collector
    Serial collector is the most basic, the development of the oldest collector, was the only option the new generation of virtual machines collected. Serial Collector Collector is a single-threaded, not only use a CPU and thread, and when garbage collection will suspend all other work thread until it collects end. This is called "Stop The World", a thread when the user is not visible to the user all the work stopped, for many applications it may be difficult to accept. However Serial collector has a simple and efficient advantages for the environment is limited to a single CPU, Serial no collector due to the overhead of thread interactions, concentrate on garbage collection can naturally obtain the highest single-threaded collection efficiency. At present, it runs Serial collector Java virtual machine in client mode. Garbage collection for the new generation.


    6051634-0e53c1a3cc46f2c5.png
    Serial collector running process
  • ParNew collector
    ParNew collector is multi-threaded version of the Serial collectors, in addition to the use of multiple threads for garbage collection, the other acts include all control parameters Serial Collector available collection algorithms, Stop The World, object allocation rule, recovery strategies are exactly the same as Serial collector.

6051634-e79c514b6629bb04.png
ParNew collector workflow

Currently ParNew collector Server is running in a virtual machine mode of choice for the new generation garbage collector.

  • Parallel Scavenge收集器
    Parallel Scavenge收集器是一个新生代收集器,它也是使用复制算法的收集器,又是并行的多线程收集器,特点是Parallel Scavenge收集器目标是达到一个可控制的吞吐量(Throughput),而其他收集器的关注点则是尽可能的减少垃圾收集时用户线程的停顿时间。吞吐量就是CPU用户运行用户代码的时间与CPU总消耗时间的比值,即 吞吐量 = 运行用户代码时间 / (运行用户代码时间+ 垃圾收集时间)。停顿时间越短就越适合需要与用户交互的程序,具有良好的响应速度,能够提升用户体验;而高吞吐量则可以高效率的利用CPU时间,尽快完成程序的运算任务,主要适合在后台运算而不太需要交互的任务。

  • Serial Old收集器
    Serial Old是Serial收集器的老年代版本,它同样是一个单线程收集器,使用标记-整理算法。主要意义还是给Client模式下的虚拟机使用。


    6051634-a41b50be21505a1c.png
    Serial Old收集器工作流程
  • Parallel Old collector
    Parallel Old Parallel Scavenger is a collector's version of the old, multi-threading, and tags to organize algorithm. The collector is available starting JDK 1.6, Parallel Scavenger again before the new generation of collectors has been in a rather awkward state. The reason is that if the new generation is the Parallel Scavenger collector's addition to the old Serial Old no choice, because the Parallel Scavenger CMS collector and the collector (later will introduce the collector) can not work together. Since the Serial Old on the service side performance of "drag", using the Parallel Scavenger collector may not be able to maximize throughput. Serial Old single-threaded server-side collector can not use multi-CPU processing power, resulting in poor throughput. And after Parallel Old occur, and can be used with Parallel Scavenger collectors, use and pay attention to the throughput and CPU resources sensitive applications.


    6051634-87bfc8732afad362.png
    Parallel Old collectors

Reproduced in: https: //www.jianshu.com/p/b971a866be2b

Guess you like

Origin blog.csdn.net/weixin_34183910/article/details/91088924