当前位置:网站首页>JVM garbage collector
JVM garbage collector
2022-07-02 10:58:00 【Big fish eating cats】
Preface
Last time JVM Garbage collection algorithm , After the foreshadowing of the previous article, this article focuses on JVM Of GC Recyclers , The main contents are referred to 《 In depth understanding of Java virtual machine 》.
This article focuses on CMS and G1GC, Other recyclers will be directly carried by .
One 、 Common garbage collectors
Here are JDK8-JDK9 Common garbage collector combinations :
From the above figure, we can draw a conclusion :
- JDK8 Supported garbage collection combinations are :Serial+Serial Old,Parallel Scavenge+Parallel Old,CMS+ParNew,Parallel Scavenge+Serial Old,G1 Five combinations ;
- JDK9 stay JDK8 On the basis of the new Serial + CMS,ParNew+Serial Old Two combinations .
among JDK8 default GC The combination is Parallel Scavenge+Parallel Old,JDK9 Default GC yes G1GC.
Two 、CMS The collector
1. brief introduction
CMS(concurrent mark sweep) Collector is a kind of collector that aims to obtain the shortest recovery pause time .
From its name (mark sweep) You can see that it is based on tags - Clear algorithm implementation .
2. Collection process
The process is relatively complicated , There are mainly 4 part :
- Initial marker , Just mark it GC Roots Objects that can be directly related , Short time , Meeting STW;
- Concurrent Tags , from GC Roots The process of traversing the whole object graph begins with the directly related object , Time consuming . Execute with user thread , There is no need to pause .
- Re label , Increment mark , Resolve the objects that cause tag changes during user thread runtime during concurrent tagging , Less time consuming , Meeting STW( The solution is the recyclable garbage added by the user thread during concurrent marking );
- Concurrent elimination , Objects that are judged to be dead in the clear and delete mark stage . Because it is executed together with the user thread , There is no need to pause .
3. Advantages and disadvantages
advantage :
Concurrent collection , Low pause .
shortcoming :
- Because it is a concurrent collection, it is very sensitive to processor resources , Will take up part of CPU;
- Based on tags - Clear algorithm implementation , There is a memory fragmentation problem ( Mark - Clear algorithm problems );
- Can't handle floating garbage , User threads are running in both the concurrent marking and concurrent cleanup phases , The garbage generated during this period can only be left for the next collection , This is floating garbage .
3、 ... and 、G1 The collector
1. brief introduction
G1 Collector is a milestone in the development of garbage collector technology , It pioneers the design idea of collector for local collection and is based on region Memory form of layout ( Physical zoning , Logical generation ).
It is worth mentioning that JDK8 Support G1GC,JDK9 Default garbage collector , And CMS Reduced to a deprecated garbage collector , As if CMS Alternative optimized version .
It is no longer measured by which generation it belongs , It's about which memory holds the most garbage , Maximum return , namely Mixed GC Pattern .
2. Collection process
There are mainly 4 A process :
- Initial marker , Mark GC Roots Objects that can be directly related to ( For a short time STW);
- Concurrent Tags , from GC Roots Start the reachability analysis of the objects in the heap , Recursively scan the whole heap to find the object to be recycled , Execute in parallel with the user thread ( There is no need to pause , Longer time consuming );
- Final marker , Increment mark , Resolve the objects that cause tag changes during user thread runtime during concurrent tagging ( Shorter STW);
- Screening markers , Is responsible for updating Region Statistical data , To each Region Sorted by recovery value and cost , Make a recycling plan based on the user's expected pause time , You can choose any number Region Make up a recycling set , Then decide to recycle that part Region Of live objects copied to empty region in , And clean up the whole old region All the space of ( Longer STW, Core design , The expected delay time can be set . The default is 200ms).
3. Advantages and disadvantages
advantage :
1. Use alone , There's no need to combine , Less parameters , Low tuning cost ;
2. You can set the estimated pause time ;
3. There will be no memory fragmentation ( A collector based on tag collation Algorithm ).
shortcoming :
1. Need more memory support ( branch region);
2. Yes CPU Multi core is required ( Many concurrent operations ).
summary
In large memory (>=6G) Under the system, if you choose to use CMS and G1 Recommended G1; On the contrary, the system has small memory (<6G) Because of G1GC Partitions occupy more space , In theory, it will be better than CMS Bad .
边栏推荐
- K-d tree and octree of PCL
- UVM - usage of common TLM port
- 正则及常用公式
- shell编程01_Shell基础
- PCL Eigen介绍及简单使用
- UWA报告使用小技巧,你get了吗?(第四弹)
- MongoDB 学习整理(条件操作符,$type 操作符,limit()方法,skip() 方法 和 sort() 方法)
- [visual studio] visual studio 2019 community version cmake development environment installation (download | install relevant components | create compilation execution project | error handling)
- 对话吴纲:我为什么笃信“大国品牌”的崛起?
- Ks009 implement pet management system based on SSH
猜你喜欢
快应用中实现自定义抽屉组件
《实习报告》Skywalking分布式链路追踪?
[visual studio] visual studio 2019 community version cmake development environment installation (download | install relevant components | create compilation execution project | error handling)
2022-06-17
Kustomize user manual
Common methods of JS array
【AGC】构建服务3-认证服务示例
HDU1236 排名(结构体排序)
Dialogue Wu Gang: why do I believe in the rise of "big country brands"?
Leetcode+ 76 - 80 storm search topic
随机推荐
Hdu1228 a + B (map mapping)
PCL 从一个点云中提取一个子集
点云投影图片
二叉树专题--【深基16.例7】普通二叉树(简化版)(multiset 求前驱 后继 哨兵法)
[SUCTF2018]followme
JSP webshell免杀——webshell免杀
对话吴纲:我为什么笃信“大国品牌”的崛起?
Shutter - canvas custom graph
PCL extracts a subset from a point cloud
Hdu1236 ranking (structure Sorting)
SUS系统可用性量表
MySQL lethal serial question 3 -- are you familiar with MySQL locks?
Learn open62541 -- [66] UA_ Generation method of string
JS settimeout() and interview questions
Mysql database remote access permission settings
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
实验电镜距离测量之Matlab处理
PCL point cloud to depth image
MYSQL环境配置
UWA report uses tips. Did you get it? (the fourth bullet)