当前位置:网站首页>JVM foundation > G1 garbage collector
JVM foundation > G1 garbage collector
2022-06-12 22:09:00 【Ouhuang xiaodezi】
say something G1 Garbage collector
G1 overview
G1 GC The full name is Garbage First Garbage Collector, Garbage priority garbage collector , hereinafter referred to as G1.
G1 yes HotSpot JVM Of
Short pause garbage collector.In fact, about G1 My thesis dates back to 2004 In, there was , however G1 Is in 2012 year 4 Released on
JDK 7u4It's only in the middle of the world .In the long run ,G1 Aimed at
replace CMS(Concurrent Mark Sweep) Garbage collector .G1 from JDK9 Started as
Default garbage collector.If pause time is more important to an application than throughput ,G1 It's a very suitable choice .
On the whole G1 It has the following characteristics :
- G1 Still generational ( The younger generation , Old age ) The garbage collector
- G1 Two garbage collection algorithms are implemented ->
Mark - Copy algorithm+Mark - Sorting algorithm - G1 There is no need to recycle all the garbage in the heap at one time ,G1 A piece of memory with too much garbage will be dynamically selected for priority recycling
- And you can specify the desired pause time
G1 Innovative design of waste recycling
Memory layout
G1Although it is still divided into generations ( The younger generation , Old age ) The garbage collector , But it no longer follows the generational arrangement of objects in the heap , Instead, the heap is divided into several equal sized areas .

But to become :
Equalize heap memory into small chunks (Region), This little piece (Region) How big is controllable
Through parameters
-XX:G1HeapRegionSize=nYou can specify the partition size (1MB~32MB, And it must be 2 The power of )By default, the whole heap is divided into 2048 Zones -> If the heap is 2g, So every little piece (Region) Namely 1M
Humongous: When you allocate more than half of an object area (Region) The size of ( exceed 0.5M when ), This object will be placed in this area . This area belongs to the old age area .
G1 Garbage collection process
G1 Garbage collection mainly includes 2 individual :
- Cenozoic recycling process (young gc) -> Recycling
- Applications allocate memory , When the new generation Eden When the zone is exhausted, the new generation recycling process begins
- Mixed recycling process (mixed gc) -> Recycling
- When the heap memory usage reaches a certain value ( Default 45%) when , Start the old age concurrent tagging process , Mark complete and start the mixed recycling process immediately .
Cenozoic recycling process
The general logic will not change much :The living object is transferred to a / Or more survivor Put it on the block . If the survival time reaches the threshold , This part of the object will be promoted to the old age .
Mixed recycling process
Initial marker
Just mark GC roots Objects that can be directly related to . This step requires STW, But the time is very short .Concurrent Tags
from GC roots Using reachability algorithms , Mark objects in heap memory (Tricolor notation), Recursively scans the entire heap . This step takes too long , It is executed concurrently with the user business program .Re label
For user threads For a short time STW, Used to handle the finalization of some changes to objects in concurrent markup .Screening and recovery
G1 According to the pause time specified by the user , Maximum recycling region, Will need to be recycled region Copy to blank region in , Then put the original region All recycled . The Steps also require STW, Because it involves the movement of objects ( One region To another region).
边栏推荐
- flutter系列之:flutter中常用的GridView layout详解
- June training (day 11) - matrix
- OceanBase 社区版 OCP 功能解读
- MySQL architecture and basic management (II)
- Leetcode: the maximum number of building change requests that can be reached (if you see the amount of data, you should be mindless)
- [Jianzhi offer] Jianzhi offer 09 Implementing queues with two stacks
- #yyds干货盘点# 解决剑指offer:字符流中第一个不重复的字符
- 大学期间零基础如何开展编程学习
- Preliminary use of jvisualvm
- SQL tuning guide notes 10:optimizer statistics concepts
猜你喜欢

MySQL体系结构及基础管理(二)

Ansible PlayBook et ansible roles (3)

SQL调优指南笔记8:Optimizer Access Paths

多线程模型下的生产者消费者模式

MySQL introduction and installation (I)

Audio and video technology development weekly 𞓜 234

Ansible playbook and ansible roles (III)
![[image denoising] image denoising based on trilateral filter with matlab code](/img/f2/770a0e2938728e731c18c0a66f7c12.png)
[image denoising] image denoising based on trilateral filter with matlab code

Mr. Sun's version of JDBC (21:34:25, June 12, 2022)

How to specify your webpage's language so Google Chrome doesn't offer to translate it
随机推荐
最近公共祖先问题你真的学会了吗?
PCB封装下载网站推荐及其详细使用方法
talent showing itself! Oceanbase was selected into the 2021 "sci tech innovation China" open source innovation list
[QNX hypervisor 2.2 user manual] 4.4 build host
[sword finger offer simple] sword finger offer 24 Reverse linked list
What is embedded
Ansible playbook and variable (II)
大学期间零基础如何开展编程学习
经济学人聚焦WTO MC12:数字经济或成重要议题
MySQL体系结构及基础管理(二)
同花顺能开户吗,在同花顺开户安全么,证券开户怎么开户流程
MySQL介绍和安装(一)
SQL tuning guide notes 10:optimizer statistics concepts
Pat grade A - 1167 Cartesian tree (30 points) (buildtree + level traversal)
2022-02-28 incluxdb high availability planning
Design and practice of Hudi bucket index in byte skipping
Audio and video technology development weekly 𞓜 234
lambda表达式与流优化代码
Redis optimization
Ansible foundation and common modules (I)