当前位置:网站首页>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).
边栏推荐
- How to develop programming learning with zero foundation during college
- Xingda easy control modbustcp to profibusdp
- What are thread scheduler and timeslicing?
- Can tonghuashun open an account? Is it safe to open an account in tonghuashun? How to open a securities account
- Is it safe to open an account in tonghuashun? How to open an account
- talent showing itself! Oceanbase was selected into the 2021 "sci tech innovation China" open source innovation list
- SQL tuning guide notes 10:optimizer statistics concepts
- Preliminary use of jvisualvm
- [sword finger offer] sword finger offer 35 Replication of complex linked list
- 2021 rust survey results released: 9354 questionnaires collected
猜你喜欢

建立高可用的数据库

Recommended Chinese font in the code input box of Oracle SQL developer

SQL调优指南笔记6:Explaining and Displaying Execution Plans

【数据分析】基于 kmeans实现数据聚类分组含Matlab源码

LNMP platform docking redis service

Qt Quick 3D学习:鼠标拾取物体

SQL tuning guide notes 14:managing extended statistics

Pat grade A - 1167 Cartesian tree (30 points) (buildtree + level traversal)

最近公共祖先问题你真的学会了吗?

Cloning PDB with ADG standby
随机推荐
"Oracle database parallel execution" technical white paper reading notes
[qnx hypervisor 2.2 manuel de l'utilisateur] 4.2 environnement de construction pris en charge
Ansible-大总结(六)
What is the race condition? How do you find and solve the competition?
How to prevent phishing emails? S/mime certificate to help!
Things about the kotlin collaboration process - pipeline channel
孙老师版本JDBC(2022年6月12日21:34:25)
多线程模型下的生产者消费者模式
经济学人聚焦WTO MC12:数字经济或成重要议题
[machine learning] learning notes 01- introduction
Modstartcms modular station building system v3.3.0 component function upgrade, event triggering enhancement
[QNX hypervisor 2.2 user manual] 4.4 build host
Why is pain rating important?
MySQL architecture and basic management (II)
JVisualVM初步使用
Vagrantbox reinstalling the vboxsf driver
June training (day 12) - linked list
【QNX Hypervisor 2.2 用户手册】4.2 支持的构建环境
Lambda expression and flow optimization code
Leetcode: the maximum number of building change requests that can be reached (if you see the amount of data, you should be mindless)