当前位置:网站首页>JVM GC garbage collection brief
JVM GC garbage collection brief
2022-07-07 20:00:00 【Whiteye too white】
GC
in the light of java Pile recycling .
Reachability analysis algorithm : from gc root Search for reference chains .
Eden Trigger when area is full minor gc, The surviving object enters survivor District ( Copy algorithm ), Age plus 1, When the age of the object is greater than the threshold ( Default 15) when , Into the old age . You can set the threshold through parameters , The virtual machine will be dynamically adjusted during operation . When a certain age exceeds survivor Half of the area ( Default 50%) when , Take this age and MaxTenuringThreshold As the new threshold .
The new generation ( Mark - Copy algorithm )
- Mark living objects - Because there are fewer surviving objects
- Memory size eden:to:from = 8 : 1 : 1
- minor gc after ,Eden The objects that live in the area are copied to “survivor To”;“survivor From” The living objects in the zone , When the age reaches the threshold, we enter the old generation , Otherwise it will be copied to “survivor To” in .survivor From and survivor To swap .
- survivor From Out of space , The part that cannot be put down will enter the elderly generation ahead of time .
Old age ( Mark - eliminate - Sorting algorithm )
When there is not enough memory in the old age full gc( Mark - eliminate ), many times full gc After finishing . Frequency parameter CMSFullGCsBeforeCompaction The default is 0 Time .
Strong citation :gc No recovery .
Soft citation : Only recycle when memory is insufficient .
Weak reference :gc Recycling .
Virtual reference : Before recycling , Get the system notification , Some treatment can be done before recycling .
java Memory model
- Program counter : Control program execution .
- Java Virtual machine stack : Store local variable table 、 The stack of operands 、 Dynamic connection 、 Method export, etc .
- Native Method Stack : Store local (native) Methods information .
- Java Pile up : Stored object instance .
- Method area : Storing static data ( Constant 、 Static variables, etc ). Contains the runtime constant pool : Store constants .
Java Heap reclamation Algorithm
- Reference counting ( Most virtual machines do not )
- Reachability analysis algorithm
according to “ Root object ” Search its “ References to the chain ” Judge whether an object is reachable , Filter unreachable objects , If the object exists finalize() Method , also finalize() Method has not been implemented , Then put the object in the queue , from Finalizer The thread executes its finalize() Method to release the object . If the object in the queue is executing finalize() Re referenced before release , Will be moved out of the release queue .JDK9 After being removed .
Recovery object judgment
- Reclaim string constants that do not have references ( String constant pool in heap , The runtime constant pool is in the method area )
- Class not in use , just “ Allowed to recycle ”
At the same time satisfy :
All instances of this class are recycled ;
The class loader for this class has been recycled ;
Of the class Class The object does not exist and is referenced , Unable to launch access .
GC The trigger condition
Minor GC The trigger condition :Eden Area is full .
Full GC The trigger condition :
- call System.gc when , System recommendation implementation Full GC, But not necessarily .
- There is not enough space in the old age .
- Insufficient method space .
- adopt Minor GC The average size of backward into old age is larger than the available memory of old age .
- from Eden District 、From Space District direction To Space When copying , The object size is greater than To Space Available memory , Then transfer the object to the old age , And the available memory of the old age is smaller than the size of the object .
【 Add 】 JDK 7 Before ,HotSpot When using the permanent generation to implement the method area , Implementation is completely in line with this logical concept . And in the JDK 7 And after ,HotSpot Already put the string constant pool originally in the permanent generation 、 Static variables, etc. are moved to the heap , At this time, class variables will follow Class Objects are stored together in Java In the pile .
边栏推荐
- LeetCode_7_5
- A pot of stew, a collection of common commands of NPM and yarn cnpm
- 国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
- Install mysql8 for Linux X ultra detailed graphic tutorial
- 毕业季|遗憾而又幸运的毕业季
- PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!
- Some arrangements about oneself
- The strength index of specialized and new software development enterprises was released, and Kirin Xin'an was honored on the list
- R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
- sql 常用优化
猜你喜欢
随机推荐
YoloV6:YoloV6+Win10---训练自己得数据集
Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
Mysql, sqlserver Oracle database connection mode
sql 常用优化
华南X99平台打鸡血教程
Ucloud is a basic cloud computing service provider
开源OA开发平台:合同管理使用手册
Semantic SLAM源码解析
AD域组策略管理
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
MySQL、sqlserver oracle数据库连接方式
使用高斯Redis实现二级索引
R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图、设置palette参数自定义不同水平小提琴图的填充色、add参数在小提琴图添加箱图
R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
Nunjuks template engine
Browse the purpose of point setting
pom.xml 配置文件标签作用简述
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
一锅乱炖,npm、yarn cnpm常用命令合集
How to cooperate among multiple threads