当前位置:网站首页>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 .
边栏推荐
- How to cooperate among multiple threads
- torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
- Boot 和 Cloud 的版本选型
- Sword finger offer II 013 Sum of two-dimensional submatrix
- JVM GC垃圾回收简述
- 【Confluence】JVM内存调整
- How to buy stocks on your mobile phone and open an account? Is it safe to open an account
- mysql 的一些重要知识
- Install mysql8 for Linux X ultra detailed graphic tutorial
- [confluence] JVM memory adjustment
猜你喜欢
随机推荐
现在股票开户可以直接在网上开吗?安全吗。
what‘s the meaning of inference
注解。。。
831. KMP string
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
vulnhub之tre1
# 欢迎使用Markdown编辑器
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
Interpretation of transpose convolution theory (input-output size analysis)
841. String hash
[confluence] JVM memory adjustment
开源OA开发平台:合同管理使用手册
9 atomic operation class 18 Rohan enhancement
R语言ggplot2可视化:使用ggpubr包的ggecdf函数可视化分组经验累积密度分布函数曲线、linetype参数指定不同分组曲线的线型
Make insurance more "safe"! Kirin Xin'an one cloud multi-core cloud desktop won the bid of China Life Insurance, helping the innovation and development of financial and insurance information technolog
LeetCode_ 7_ five
一锅乱炖,npm、yarn cnpm常用命令合集
ant desgin 多选