继续基于上一次https://www.cnblogs.com/webor2006/p/11135005.html的官方G1文档进行解读,上一次分析到了这:

话不多说,继续往前读:

When performing garbage collections, G1 operates in a manner similar to the CMS collector. G1 performs a concurrent global marking phase to determine the liveness of objects throughout the heap. After the mark phase completes, G1 knows which regions are mostly empty. It collects in these regions first, which usually yields a large amount of free space. This is why this method of garbage collection is called Garbage-First. As the name suggests, G1 concentrates its collection and compaction activity on the areas of the heap that are likely to be full of reclaimable objects, that is, garbage. G1 uses a pause prediction model to meet a user-defined pause time target and selects the number of regions to collect based on the specified pause time target.

【解读:

“When performing garbage collections, G1 operates in a manner similar to the CMS collector.”

在执行垃圾收集的时候,G1的操作行为方式类似于CMS收集器很。

“G1 performs a concurrent global marking phase to determine the liveness of objects throughout the heap. After the mark phase completes, G1 knows which regions are mostly empty. ”

G1会执行一个并发的全局标记的阶段来去确定整个堆当中对象的存活情况。在标记阶段完成之后,G1就知道哪个区域几乎是空的【言外之后,也就是经过G1的标记之后就能清楚哪些区域存活的对象多,哪些存活的对象少了】。

“It collects in these regions first, which usually yields a large amount of free space. This is why this method of garbage collection is called Garbage-First. ”

它就会优先收集这些区域,这样就能产生大量的可用空间,这就是为什么这种垃圾收集器的方式称之为Garbage-Firt原因之所在。

“As the name suggests, G1 concentrates its collection and compaction activity on the areas of the heap that are likely to be full of reclaimable objects, that is, garbage. ”

如这个名字所表示的一样,G1会重点观注它的收集和压缩活动在这些堆的区域上,而这些区域是最有可能充满了可回收的对象,也就是说,垃圾。

“G1 uses a pause prediction model to meet a user-defined pause time target and selects the number of regions to collect based on the specified pause time target.”

G1使用了一个停顿可预测的模型来满足一个用户定义的暂停时间的目标,并且会选择一定数量的区域来进行回收,它是基于一个用户所指定的暂时间目标。

The regions identified by G1 as ripe for reclamation are garbage collected using evacuation. G1 copies objects from one or more regions of the heap to a single region on the heap, and in the process both compacts and frees up memory. This evacuation is performed in parallel on multi-processors, to decrease pause times and increase throughput. Thus, with each garbage collection, G1 continuously works to reduce fragmentation, working within the user defined pause times. This is beyond the capability of both the previous methods. CMS (Concurrent Mark Sweep ) garbage collector does not do compaction. ParallelOld garbage collection performs only whole-heap compaction, which results in considerable pause times.

【解读:

“The regions identified by G1 as ripe for reclamation are garbage collected using evacuation. ”

由G1标识出来的区域是完全可以做为垃圾来回收的。

“G1 copies objects from one or more regions of the heap to a single region on the heap, and in the process both compacts and frees up memory. ”

G1会从堆中的一个或者多个区域复制对象到堆中的另外一个单个区域,而且在复制这个过程当中还会进行压缩并且释放内存。【这里解释一下,比如图中这些区域存活的对象总大小只会占用一个区域的大小了:

这时就会将这三个存活的对象一起复制到另一个单个的区域中,比如Survivor中,如一下:

在存放到S时还会进行压缩,这时原来三个Eden Space中的空间就会得到释放可以用于其它对象的存放了。

“This evacuation is performed in parallel on multi-processors, to decrease pause times and increase throughput. Thus, with each garbage collection, G1 continuously works to reduce fragmentation, working within the user defined pause times. ”

这种回收在多处理器上是并行执行的,从而减少停顿的时间并且还能增加吞吐量。因此,对于每一个垃圾收集来说,G1会持续的工作来减少碎片的产生,而且是运行在用户所指定的停顿时间之内。

“This is beyond the capability of both the previous methods. CMS (Concurrent Mark Sweep ) garbage collector does not do compaction. ParallelOld garbage collection performs only whole-heap compaction, which results in considerable pause times.”

这完全超出了原来垃圾收集器的能力。CMS垃圾收集器并不会进行压缩。而ParallelOld垃圾收集器只会执行整个堆的压缩,这样就会耗费相当长的暂停时间。

It is important to note that G1 is not a real-time collector. It meets the set pause time target with high probability but not absolute certainty. Based on data from previous collections, G1 does an estimate of how many regions can be collected within the user specified target time. Thus, the collector has a reasonably accurate model of the cost of collecting the regions, and it uses this model to determine which and how many regions to collect while staying within the pause time target.

【解读:

“It is important to note that G1 is not a real-time collector. It meets the set pause time target with high probability but not absolute certainty. ”

值得关注的重点是G1并非是一个实时的收集器,它会尽最大的可能满足用户有所设定的停顿时间目标,但并非绝对精准。

“Based on data from previous collections, G1 does an estimate of how many regions can be collected within the user specified target time. ”

根据之前收集器的一些数据,G1会做一个近视的估量在用户所指定的目标时间内到底能收集多少个区域。

“Thus, the collector has a reasonably accurate model of the cost of collecting the regions, and it uses this model to determine which and how many regions to collect while staying within the pause time target.”

这样的话,收集器就会有一个相对精确的收集区域成本的模型,并且用这个模型来确定哪些以及多少区域要被收集才能满足停顿时间的目标。

Note: G1 has both concurrent (runs along with application threads, e.g., refinement, marking, cleanup) and parallel (multi-threaded, e.g., stop the world) phases. Full garbage collections are still single threaded, but if tuned properly your applications should avoid full GCs.

【解读:

Note: G1 has both concurrent (runs along with application threads, e.g., refinement, marking, cleanup) and parallel (multi-threaded, e.g., stop the world) phases. ”

说明:G1既拥有并发(同应用线程同时运行,如标记、清除等),又有并行(多个线程,比如说STW)阶段。

“Full garbage collections are still single threaded, but if tuned properly your applications should avoid full GCs.”

Full GC依然是单线程的,但是如果调优得比较好的话你就应用应该尽量Full GC的情况发生。

接着来看一下“G1 Footprint”,也就是G1物理占用的空间,如下:

If you migrate from the ParallelOldGC or CMS collector to G1, you will likely see a larger JVM process size. This is largely related to "accounting" data structures such as Remembered Sets and Collection Sets.

如果你从ParallelOldGC或者CMS收集器往G1来迁移的话,你会看到一个更大的JVM处理的大小。这是因为跟“RSet”和“CSet”的数据结构相关。【这个在之前的理论中也学习过了,如:

Remembered Sets or RSets track object references into a given region. There is one RSet per region in the heap. The RSet enables the parallel and independent collection of a region. The overall footprint impact of RSets is less than 5%.

已记忆集合或者也称之为RSet,它会追踪到一个指定区域的对象引用。在堆中的每一个区域都有一个RSet。这个RSet使得并行和独立区域的收集成为可能。整体RSets的大小应该是小于5%。

Collection Sets or CSets the set of regions that will be collected in a GC. All live data in a CSet is evacuated (copied/moved) during a GC. Sets of regions can be Eden, survivor, and/or old generation. CSets have a less than 1% impact on the size of the JVM.

收集集合又称为CSet,它会设置在GC当中会被收集的区域,在CSets当中所有存活的数据在GC当中都会被拷贝或复制。区域的集合可能是Eden、survivor或者是Old generation,CSets在整个JVM的的大小会少于1%。

继续,“Recommended Use Cases for G1,G1推荐的使用场景”,如下:

The first focus of G1 is to provide a solution for users running applications that require large heaps with limited GC latency. This means heap sizes of around 6GB or larger, and stable and predictable pause time below 0.5 seconds.

G1的第一关注点是为用户提供一种解决方案,其用户群体是他们运行的应用需要大的堆空间并且是有限的GC的延迟。这个意味着堆空间大小大于是在6G左右或者更大,并且稳定可预测的间隔时间应该是在0.5s之内。

Applications running today with either the CMS or the ParallelOldGC garbage collector would benefit switching to G1 if the application has one or more of the following traits.

在现在应用使用从CMS或者ParallelOldGC垃圾收集器都会从切换至G1受益,如果应用拥有如下几个特点:

      • Full GC durations are too long or too frequent.
        Full GC的持续时间太长或太频繁了。
      • The rate of object allocation rate or promotion varies significantly.
        对象分派或晋升率比较大。
      • Undesired long garbage collection or compaction pauses (longer than 0.5 to 1 second)
        不需要长时间的垃圾收集或者停顿的间隔(通常是长于0.5或1秒)

Note: If you are using CMS or ParallelOldGC and your application is not experiencing long garbage collection pauses, it is fine to stay with your current collector. Changing to the G1 collector is not a requirement for using the latest JDK.
说明:如果你使用了CMS或者ParallelOldGC,并且你的应用并没有经历过长时间的垃圾收集停顿时间,还是可以继续保持你现有的收集器的,切换成G1收集器对于使用了最新版的JDK来说并不是一个需求。

至此咱们就把这三部分的东东给解读完了,如下:

G1垃圾收集器原理剖析【官方解读】的更多相关文章

  1. G1 垃圾收集器深入剖析(图文超详解)

    G1(Garbage First)垃圾收集器是目前垃圾回收技术最前沿的成果之一. G1 同 CMS 垃圾回收器一样,关注最小时延的垃圾回收器,适合大尺寸堆内存的垃圾收集.但是,G1 最大的特点是引入分 ...

  2. G1垃圾收集器系统化说明【官方解读】

    还是继续G1官网解读,上一次已经将这三节的东东读完了,如下: 所以接一来则继续往下读: Reviewing Generational GC and CMS[回顾一下CMS收集器] The Concur ...

  3. G1垃圾收集器官方文档透彻解读【官方解读】

    在前几次中已经对G1的理论进行了一个比较详细的了解了,对于G1垃圾收集器最权威的解读肯定得上官网,当咱们将官网的理解透了,那基本上网上对于G1的说明其实最终都是来自于官网,所以接下来会详细来解读Ora ...

  4. G1垃圾收集器的实现原理

    (G1垃圾收集器的实现原理.G1和CMS经常被单独拎出来问) https://tech.meituan.com/g1.html G1太复杂,说下CMS吧

  5. 深入理解 Java G1 垃圾收集器--转

    原文地址:http://blog.jobbole.com/109170/?utm_source=hao.jobbole.com&utm_medium=relatedArticle 本文首先简单 ...

  6. 【JVM】7、深入理解Java G1垃圾收集器

    本文首先简单介绍了垃圾收集的常见方式,然后再分析了G1收集器的收集原理,相比其他垃圾收集器的优势,最后给出了一些调优实践. 一,什么是垃圾回收 首先,在了解G1之前,我们需要清楚的知道,垃圾回收是什么 ...

  7. 转:深入理解Java G1垃圾收集器

    本文首先简单介绍了垃圾收集的常见方式,然后再分析了G1收集器的收集原理,相比其他垃圾收集器的优势,最后给出了一些调优实践. 一,什么是垃圾回收 首先,在了解G1之前,我们需要清楚的知道,垃圾回收是什么 ...

  8. [转] 深入理解Java G1垃圾收集器

    [From] https://www.cnblogs.com/ASPNET2008/p/6496481.html 深入理解Java G1垃圾收集器 本文首先简单介绍了垃圾收集的常见方式,然后再分析了G ...

  9. 深入理解Java G1垃圾收集器

    本文首先简单介绍了垃圾收集的常见方式,然后再分析了G1收集器的收集原理,相比其他垃圾收集器的优势,最后给出了一些调优实践. 一,什么是垃圾回收 首先,在了解G1之前,我们需要清楚的知道,垃圾回收是什么 ...

随机推荐

  1. MockMvc 进行 controller层单元测试 事务自动回滚 完整实例

    package com.ieou.ms_backend.controller; import com.google.gson.Gson; import com.ieou.ms_backend.dto. ...

  2. DevOps - DevOps精要 - 歧途

    前言 如果在实施DevOps的过程中,周围没有一个人支持你,也没有得到领导和团队成员的理解: 如果在采用DevOps的工具和方法之后,难以获得明显的效率提升,甚至得到了不少的消极反馈: 那就需要反省一 ...

  3. iOS-打印控件

    20.UIPrintFormatterUIPrintFormatter时打印格式化的抽象基类:展示了传统的可打印的内容对象可以跨页边界.由于打印格式化,打印系统,可以自动打印与打印格式化的内容相关联的 ...

  4. Configuring and Running Django + Celery in Docker Containers

    Configuring and Running Django + Celery in Docker Containers  Justyna Ilczuk  Oct 25, 2016  0 Commen ...

  5. 虚拟机中windows下制作超级隐藏账户

    这篇博客非原创,我只是将很多大佬写的东西理解了一下写了出来. 接下来的实验最好在虚拟机进行,因为可以快照~ 制作隐藏用户可以说是两种方法但是基本操作一样,所以我们穿插着进行一种是隐藏账户,一种是影子账 ...

  6. 剑指offer33:求按从小到大的顺序的第N个丑数。

    1 题目描述 把只包含质因子2.3和5的数称作丑数(Ugly Number).例如6.8都是丑数,但14不是,因为它包含质因子7. 习惯上我们把1当做是第一个丑数.求按从小到大的顺序的第N个丑数. 2 ...

  7. Mysql的多机配置(主从、主主等)

    前言: 最近这几天给弄了2台机器,部署centlos7.5,除了公司的一些模块外,给2台机器做了下主主备份. 其实网上资料一大堆,但是感觉按照别人的思路不如自己的舒服,虽然这玩意思路差不多,但是还是在 ...

  8. 二十一、RTC驱动

    一.RTC设备驱动分析 内核的rtc驱动位于内核drivers/rtc目录下,里面包含各个平台的RTC驱动.读者可在此目录下任意选择一个单板驱动文件进行分析,我选择的是rtc-davinci.c文件. ...

  9. IdentityServer4 手动验签及日志记录

    IdentityServer4的基础知识和使用方式网上有很多特别优秀的文章,如果有对其不了解的推荐阅读一下下面的两篇文章 http://www.ruanyifeng.com/blog/2014/05/ ...

  10. 修改mysql远程数据库链接密码(转)

    原文:https://blog.csdn.net/jianjiao7869/article/details/81029171 原来root用户有两个,一个只允许localhost登陆,一个可运行所有用 ...