当前位置:网站首页>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 .
边栏推荐
- IP tools
- JVM 类加载机制
- 注解。。。
- 841. String hash
- IP 工具类
- what‘s the meaning of inference
- J ü rgen schmidhub reviews the 25th anniversary of LSTM papers: long short term memory All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversar
- Training IX basic configuration of network services
- 开源重器!九章云极DataCanvas公司YLearn因果学习开源项目即将发布!
- Kirin Xin'an with heterogeneous integration cloud financial information and innovation solutions appeared at the 15th Hunan Financial Technology Exchange Conference
猜你喜欢
Compiler optimization (4): inductive variables
国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
LeetCode_ 7_ five
The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared
PMP practice once a day | don't get lost in the exam -7.7
mock.js从对象数组中任选数据返回一个数组
最多可以参加的会议数目[贪心 + 优先队列]
Interpretation of transpose convolution theory (input-output size analysis)
Kirin Xin'an joins Ningxia commercial cipher Association
随机推荐
MIT科技评论文章:围绕Gato等模型的AGI炒作可能使人们忽视真正重要的问题
开源OA开发平台:合同管理使用手册
Sword finger offer II 013 Sum of two-dimensional submatrix
力扣 643. 子数组最大平均数 I
vulnhub之Funfox2
[sword finger offer] sword finger offer II 012 The sum of left and right subarrays is equal
Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!
Time tools
what‘s the meaning of inference
Download from MySQL official website: mysql8 for Linux X Version (Graphic explanation)
剑指 Offer II 013. 二维子矩阵的和
R language uses ggplot2 function to visualize the histogram distribution of counting target variables that need to build Poisson regression model, and analyzes the feasibility of building Poisson regr
2022年投资哪个理财产品收益高?
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
torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
ASP.NET幼儿园连锁管理系统源码
Simulate the implementation of string class
Kirin Xin'an with heterogeneous integration cloud financial information and innovation solutions appeared at the 15th Hunan Financial Technology Exchange Conference
MySQL、sqlserver oracle数据库连接方式
毕业季|遗憾而又幸运的毕业季