JVM之G1收集器
Garbage-First,面向服务端的垃圾收集器。
- 并行与并发:充分利用多核环境减少停顿时间,
- 分代收集:不需要配合其它收集器
- 空间整合:整体上看属于标记整理算法,局部(region之间)数据复制算法,运作期间不会产生空间碎片
- 停顿可预测,建立可以预测的停顿时间模型。
内存管理:
- 将整个java堆划分为多个大小形同的区域region,新生代和老年代都是region的集合。可以有计划的避免在全区域内进行垃圾收集。
- 回收方式:跟踪每一个region里面的垃圾堆积的价值大小(回收所得的空间大小以及所需耗费时间的经验值),维护一个优先列表,每次根据允许的回收时间,优先回收价值最大的region(GI名字由来),
- region之间的引用,新生代和老年带之间的引用根据remebered set来避免全盘扫描,每一个region都维护一个remebered set,
- 初始标记-》并发标记-》最终标记-》筛选回收,类CMS
Phase
|
Description
|
(1) Initial Mark (Stop the World Event)
|
This is a stop the world event. With G1, it is piggybacked on a normal young GC. Mark survivor regions (root regions) which may have references to objects in old generation.
|
(2) Root Region Scanning
|
Scan survivor regions for references into the old generation. This happens while the application continues to run. The phase must be completed before a young GC can occur.
|
(3) Concurrent Marking
|
Find live objects over the entire heap. This happens while the application is running. This phase can be interrupted by young generation garbage collections.
|
(4) Remark (Stop the World Event)
|
Completes the marking of live object in the heap. Uses an algorithm called snapshot-at-the-beginning (SATB) which is much faster than what was used in the CMS collector.
|
(5) Cleanup (Stop the World Event and Concurrent)
|
|
(*) Copying (Stop the World Event)
|
These are the stop the world pauses to evacuate or copy live objects to new unused regions. This can be done with young generation regions which are logged as [GC pause (young)]. Or both young and old generation regions which are logged as [GC Pause (mixed)].
|
Option and Default Value
|
Description
|
-XX:+UseG1GC
|
Use the Garbage First (G1) Collector:启用G1收集器
|
-XX:MaxGCPauseMillis=n
|
Sets a target for the maximum GC pause time. This is a soft goal, and the JVM will make its best effort to achieve it.:目标GC暂停时间,尽可能目标
|
-XX:InitiatingHeapOccupancyPercent=n
|
Percentage of the (entire) heap occupancy to start a concurrent GC cycle. It is used by GCs that trigger a concurrent GC cycle based on the occupancy of the entire heap, not just one of the generations (e.g., G1). A value of 0 denotes 'do constant GC cycles'. The default value is 45.:触发GC 堆使用比例,整个堆的占用比例,而不是某个分代区域,0意味着频繁收集,默认为45
|
-XX:NewRatio=n
|
Ratio of new/old generation sizes. The default value is 2.:年轻代/老年代比例 默认为2
|
-XX:SurvivorRatio=n
|
Ratio of eden/survivor space size. The default value is 8.:eden/survivor比例,默认为8,即 8 1 1
|
-XX:MaxTenuringThreshold=n
|
Maximum value for tenuring threshold. The default value is 15.:对象晋升老年代年龄阈值,默认15
|
-XX:ParallelGCThreads=n
|
Sets the number of threads used during parallel phases of the garbage collectors. The default value varies with the platform on which the JVM is running.:并行收集线程数
|
-XX:ConcGCThreads=n
|
Number of threads concurrent garbage collectors will use. The default value varies with the platform on which the JVM is running.:并发收集线程数
|
-XX:G1ReservePercent=n
|
Sets the amount of heap that is reserved as a false ceiling to reduce the possibility of promotion failure. The default value is 10.:预留座位假的堆上限百分比,默认10
|
-XX:G1HeapRegionSize=n
|
With G1 the Java heap is subdivided into uniformly sized regions. This sets the size of the individual sub-divisions. The default value of this parameter is determined ergonomically based upon heap size. The minimum value is 1Mb and the maximum value is 32Mb.:G1分割堆为等大小的region,region大小默认由jvm根据效能设置,1~32M
|
JVM之G1收集器的更多相关文章
- JVM(四) G1 收集器工作原理介绍
此篇文章半原创是对参考资料中的知识点进行总结,欢迎评论指点,谢谢! 部分知识点总结来自R大的帖子,下文有参考资料的链接 概述 G1 收集是相比于其他收集器(可见 上一篇文章),可以独立运 ...
- 深入理解JVM 垃圾收集器(下)G1收集器
1.回顾CMS 1.1堆内存结构 1.2新生代GC 1.3老年代GC 2.G1收集器 2.1G1实现概览及使用场景 G1的推荐使用场景 2.2GC 2.2.1新生代GC 2.2.2老年代GC 老年代G ...
- JVM垃圾收集器-G1收集器
G1收集器是当前收集器技术发展的最前沿成果,在JDK1.6_Updata14中提供了Early Access版本的G1收集器以供适用.G1收集器是垃圾收集器理论进一步发展的产物,它与前面的CMS收集器 ...
- JVM(11)之 G1收集器
开发十年,就只剩下这套架构体系了! >>> 在前两篇博文中讲解了新生代和年老代的收集器,在本篇博文中介绍一个收集范围涵盖整个堆的收集器--G1收集器. 先讲讲G1收集器的特点, ...
- G1收集器-原创译文[未完成]
G1收集器-原创译文 原文地址 Getting Started with the G1 Garbage Collector 目的 本文介绍了如何使用G1垃圾收集器以及如何与Hotspot JVM一起使 ...
- CMS收集器和G1收集器优缺点
首先要知道 Stop the world的含义(网易面试):不管选择哪种GC算法,stop-the-world都是不可避免的.Stop-the-world意味着从应用中停下来并进入到GC执行过程中去. ...
- JVM-如何判断对象存活与否与CMS收集器和G1收集器的区别
JVM如何判断对象存活? 1.计数器 2.可达性分析 (很多主流语言采用这种方法来判断对象是否存活) 计数器:每当有一个地方引用该对象时,计数器 +1:引用失效则 -1: 优点:实现简单,判定效率 ...
- G1收集器的收集原理
G1收集器的收集原理 来源 http://blog.jobbole.com/109170/ JVM 8 内存模型 原文:https://blog.csdn.net/bruce128/article/d ...
- G1收集器
转载:https://blog.csdn.net/zhou2s_101216/article/details/79202893 http://blog.jobbole.com/109170/ http ...
随机推荐
- 【洛谷P2258】子矩阵
子矩阵 题目链接 搜索枚举选了哪几行,将DP降为一个一维的问题, 先预处理出w[i]表示该列上下元素差的绝对值之和 v[i][j]为第i列和第j列对应元素之差的绝对值之和 f[i][j]表示前j列中选 ...
- 【题解】洛谷P2023 [AHOI2009] 维护序列(线段树)
洛谷P2023:https://www.luogu.org/problemnew/show/P2023 思路 需要2个Lazy-Tag 一个表示加的 一个表示乘的 需要先计算乘法 再计算加法 来自你谷 ...
- ssm框架基础搭建
1项目搭建环境 windows10+eclipse4.8+tomcat7+jdk1.7 2.使用maven搭建 1)首先eclipse配置好maven环境 2)file--new--other 3) ...
- 关于chrome浏览器不能更新js的问题
今天写程序时,突然发现无论我怎么改本地js,用chrome打开时,均是改动之前的效果,F12查看Sources时发现js文件并没有被改动.由此引发的问题,经查询解决方法如下: F12后按F1,出现Se ...
- 谈个人对avascript面向对象的理解
javascript,不但是javascript或者是别的语音,大多数都有一句经典的话:一切皆对象. 下面谈谈我个人对面向对象的理解,为什么要用面向对象来写js,这话我思考了很久,最后得出的结论就是: ...
- pom.xml文件报MavenArchiver错误 org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration)
第一种方式 war项目 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId> ...
- 开发和调试第一个 LLVM Pass
1. 下载和编译 LLVM LLVM 下载地址 http://releases.llvm.org/download.html,目前最新版是 6.0.0,下载完成之后,执行 tar 解压 llvm 包: ...
- JS 匿名函数或自执行函数总结
JS引擎在遇到function关键字时做如下两种处理: 1.当语句是以function关键字开头:此时的JS语句解释为函数声明,因此function关键字后面必须要跟函数名字,如果写成匿名函数,则会报 ...
- 使用ContentType处理大量的外键关系
问题分析 在之前的一个商城的项目中使用了mysql, 提到mysql就是外键, 多对多等等一系列的表关系 因为是一个商城的项目, 这里面有优惠券, 商品有很多的分类, 不同的商品又有不同的优惠券 其实 ...
- mybatis调用存过程返回结果集和out参数值
Mapper文件: 1.配置一个参数映射集,采用hashMap对象 2.使用call调用存储过,其中in out等标识的参数需要有详细的描述,例如:mode,JavaType,jdbcType等 &l ...