当前位置:网站首页>New generation garbage collector ZGC
New generation garbage collector ZGC
2022-07-06 19:56:00 【Chat with Lao Wang】
Catalog
1、 What is? ZGC
ZGC(The Z Garbage Collector) yes JDK 11 Launched in the pursuit of an ultimate low latency experimental garbage collector .
ZGC It was recently by Oracle by OpenJDK New open source garbage collector . It is mainly composed of Per Liden To write .ZGC Be similar to Shenandoah or Azul Of C4, Focus on reducing pause times while still compressing the heap .
2、ZGC Design purpose
ZGC The core of is a concurrent garbage collector , The goal of its design is :
1) The pause time shall not exceed 10ms;
2) The pause time doesn't vary with the size of the heap , Or the size of the active object ;
3) The supported heap range is 8MB~4TB Level ( Future support 16TB).

All in all , ZGC The purpose of is to reduce the pause time at the same time , Can still compress the heap .
3、ZGC present situation
Up to date JDK15 Look at ,“ The pause time shall not exceed 10ms” and “ Support 16TB A pile of ” These two goals have been achieved , And the official made it clear that JDK15 Medium ZGC No longer an experimental garbage collector , And it is suggested to put into production .
4、ZGC Core technology of Technique
4.1 Multiple mapping
Let's first look at an interesting example .
You are a son in the eyes of your parents , In your girlfriend's eyes, it's a boyfriend . In front of people all over the world is the most handsome person . You have another name , But the name is just your code name , It's not you . If your name is the only one in the world , adopt “ What's your name ”、“ Your father's son ”、“ Your girlfriend's boyfriend ”,“ The most handsome man in the world ” It's all about you in the end .

Now let's see ZGC Memory management for .
ZGC The basic unit for managing physical memory in is segment.segment Default and small page size equally , All are 2MB. introduce segment To avoid frequent system calls to request and free memory , An application 2MB, When segment Idle , Will be added to the free list , Wait and reuse .
ZGC In order to be efficient 、 Flexible memory management , Two level memory management is realized : Virtual memory and physical memory , And the mapping between physical memory and virtual memory is realized . This is basically consistent with the design idea of virtual address and physical address in the operating system .

When an application creates an object , First, apply for a virtual address in heap space ,ZGC At the same time, for the object in Marked0、Marked1 and Remapped Each of the three view spaces applies for a virtual address , And these three virtual addresses correspond to the same physical address .
stay ZGC There is only one valid space among the three spaces at the same time .
Why is it so designed ?
This is it. ZGC The brilliance of , Use virtual space for time .
The switching of these three spaces is triggered by different stages of garbage collection , By limiting three spaces to have and only one space at the same time, it can be completed effectively and efficiently GC Concurrent operation of process , This and ZGC Concurrent processing algorithm is related .ZGC The concurrent processing algorithm makes use of the switch between global spatial view and object address view , combination SATB The algorithm achieves efficient concurrency .
4.2 Dye pointer
We all know , Previous garbage collectors used to put GC Information ( Tag information 、GC Generational age ..) There is an object header Mark Word in .
and ZGC Here's how it works :
If an object is a garbage object . Mark this object as garbage in the information of this object . No matter where this object is used in the future , We all know that he is a garbage object .
ZGC Store the object information in the pointer , This technology is called —— Dye pointer (Colored Pointer).

stay 64 In a bit machine , The object pointer is 64 Bit .
ZGC Use 64 Bit address space 0~43 Bit storage object address ,2^44 = 16TB, therefore ZGC The biggest support 16TB A pile of .
And the first 44~47 Bit as a color marker bit ,Marked0、Marked1 and Remapped Represents three view flags ,Finalizable Indicates that this object can only be accessed through finalizer Ability to visit .
The first 48~63 The bit is fixed to 0 There is no use .
4.3 Reading barrier
The reading barrier is JVM The technique of inserting a small piece of code into application code . When an application thread reads an object reference from the heap , It will execute this code . Don't compare this barrier with Java The read barrier in the memory model is confused , The two are not the same thing at all ,ZGC The reading barrier is more like AOP technology , Add an extra processing to the read operation at the bytecode level or at the compile code level .
ZGC As an excellent garbage collector , It draws on Pauseless GC, But in G1 It's not popular today , talk about ZGC It seems too early . But maybe we're not talking about ZGC, It is ZGC The design idea behind it .
Official account + Input [ Interview questions ] + Get the interview materials free of charge ( Interview outline + Interview answers )!
边栏推荐
- Tencent architects first, 2022 Android interview written examination summary
- Test Li hi
- Unbalance balance (dynamic programming, DP)
- PHP与EXCEL PHPExcel
- 系统与应用监控的思路和方法
- Leetcode 30. 串联所有单词的子串
- mod_wsgi + pymssql通路SQL Server座
- Tencent T3 Daniel will teach you hand-in-hand, the internal information of the factory
- Social recruitment interview experience, 2022 latest Android high-frequency selected interview questions sharing
- MySQL information Schema Learning (i) - - General table
猜你喜欢

Tencent Android interview must ask, 10 years of Android development experience

深入浅出,面试突击版

Transformer model (pytorch code explanation)
Classic 100 questions of algorithm interview, the latest career planning of Android programmers

Tencent T3 teaches you hand in hand. It's really delicious

Blue Bridge Cup microbial proliferation C language

系统与应用监控的思路和方法

Interpretation of Dagan paper

Information System Project Manager - Chapter VIII project quality management

HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
随机推荐
激进技术派 vs 项目保守派的微服务架构之争
Hudi vs Delta vs Iceberg
1805. Number of different integers in the string
Color is converted to tristimulus value (r/g/b) (dry stock)
Example of applying fonts to flutter
Learn to explore - use pseudo elements to clear the high collapse caused by floating elements
腾讯T3大牛手把手教你,大厂内部资料
微信小程序常用集合
Crawler (14) - scrape redis distributed crawler (1) | detailed explanation
AsyncHandler
爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
Method keywords deprecated, externalprocname, final, forcegenerate
Unbalance balance (dynamic programming, DP)
小微企业难做账?智能代账小工具快用起来
PHP and excel phpexcel
Logstash expressway entrance
Using clip path to draw irregular graphics
爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
学习打卡web
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅