当前位置:网站首页>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 .
边栏推荐
- what‘s the meaning of inference
- R language dplyr package mutate_ At function and min_ The rank function calculates the sorting sequence number value and ranking value of the specified data column in the dataframe, and assigns the ra
- 华南X99平台打鸡血教程
- 使用高斯Redis实现二级索引
- openEuler 资源利用率提升之道 01:概论
- The project manager's "eight interview questions" is equal to a meeting
- Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
- What does "true" mean
- ASP. Net kindergarten chain management system source code
- R语言dplyr包mutate_at函数和min_rank函数计算dataframe中指定数据列的排序序号值、名次值、将最大值的rank值赋值为1
猜你喜欢

Kirin Xin'an won the bid for the new generation dispatching project of State Grid!

Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )

Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!

2022如何评估与选择低代码开发平台?

# 欢迎使用Markdown编辑器

Kirin Xin'an cloud platform is newly upgraded!

RESTAPI 版本控制策略【eolink 翻译】

openEuler 有奖捉虫活动,来参与一下?

干货分享|DevExpress v22.1原版帮助文档下载集合

谷歌seo外链Backlinks研究工具推荐
随机推荐
Download from MySQL official website: mysql8 for Linux X Version (Graphic explanation)
How to buy bank financial products? Do you need a bank card?
LeetCode_7_5
Visual Studio 插件之CodeMaid自动整理代码
Some arrangements about oneself
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。
转置卷积理论解释(输入输出大小分析)
[sword finger offer] sword finger offer II 012 The sum of left and right subarrays is equal
凌云出海记 | 赛盒&华为云:共助跨境电商行业可持续发展
LeetCode_ 7_ five
vulnhub之school 1
My creation anniversary
位运算介绍
使用高斯Redis实现二级索引
ASP.NET幼儿园连锁管理系统源码
Ways to improve the utilization of openeuler resources 01: Introduction
Simulate the implementation of string class
The DBSCAN function of FPC package of R language performs density clustering analysis on data, checks the clustering labels of all samples, and the table function calculates the two-dimensional contin
Introduction to bit operation