当前位置:网站首页>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 )!
边栏推荐
- 力扣101题:对称二叉树
- PHP与EXCEL PHPExcel
- Wonderful coding [hexadecimal conversion]
- Alibaba data source Druid visual monitoring configuration
- Cesium 点击绘制圆形(动态绘制圆形)
- Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe
- LeetCode_ Double pointer_ Medium_ 61. rotating linked list
- RT-Thread 组件 FinSH 使用时遇到的问题
- beegfs高可用模式探讨
- Tencent T3 teaches you hand in hand. It's really delicious
猜你喜欢
Phoenix Architecture 3 - transaction processing
学习打卡web
Tencent T2 Daniel explained in person and doubled his job hopping salary
Tencent T3 Daniel will teach you hand-in-hand, the internal information of the factory
PowerPivot——DAX(初识)
力扣101题:对称二叉树
Interpretation of Dagan paper
Swiftui game source code Encyclopedia of Snake game based on geometryreader and preference
Understand yolov1 Part II non maximum suppression (NMS) in prediction stage
Systematic and detailed explanation of redis operation hash type data (with source code analysis and test results)
随机推荐
AsyncHandler
Introduction to enterprise lean management system
POJ1149 PIGS 【最大流量】
After solving 2961 user feedback, I made such a change
Tencent T2 Daniel explained in person and doubled his job hopping salary
【云小课】EI第47课 MRS离线数据分析-通过Flink作业处理OBS数据
Lick the dog until the last one has nothing (simple DP)
Transformer model (pytorch code explanation)
Mysql Information Schema 學習(一)--通用錶
PHP and excel phpexcel
小微企业难做账?智能代账小工具快用起来
Recursive implementation of department tree
Leetcode 30. Concatenate substrings of all words
腾讯T2大牛亲自讲解,跳槽薪资翻倍
Poj1149 pigs [maximum flow]
How to access localhost:8000 by mobile phone
腾讯Android面试必问,10年Android开发经验
It's enough to read this article to analyze the principle in depth
腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
AddressSanitizer 技术初体验