当前位置:网站首页>Interviewer: why does the new generation memory need two survivor zones?
Interviewer: why does the new generation memory need two survivor zones?
2022-06-24 01:21:00 【CodingCode】
1 、Survivor Meaning of existence
Don't think about why there are two Survivor District , Imagine Survivor What is the meaning of the district ?
without Survivor,Eden Every time the district goes on Minor GC, The surviving object will be sent to the old age . In this way, the memory of the older generation will soon be used up , Trigger Major GC. Because the memory space of the old generation is much larger than that of the new generation , So do it once Full GC The ratio of time spent Minor GC Much longer , This will cause the system to execute slowly , Too slow to respond , The user experience is very bad , Not to mention that some connections may have connection errors due to timeout .
Let's think about it Survivor Under the circumstances , Is there any solution , This can be avoided :
- Increase the memory of the older generation
- The advantage is that it can bear more surviving objects , Reduce GC The frequency of
- The disadvantages are also obvious , The bigger the space , happen GC It will take longer
- Reduce old age memory
- The advantage is GC Less time required
- Weakness is GC The frequency increases
Obvious , No, Survivor Words , Neither of these solutions can fundamentally solve the problem .
So we can get the first conclusion :Survivor The meaning of being , Is to reduce the number of people sent to the old age , And then reduce Full GC Happen ,Survivor Pre screening guarantee , Only experience 16 Time Minor GC Objects that can survive in the new generation , Will be sent to the old age .
2 、 Why set up two Survivor
Set the two Survivor The biggest advantage of the zone is that it solves fragmentation
Why one Survivor Not in the district ? Suppose there is only one survivor District , Let's simulate the process :
Eden Full of , Trigger once Minor GC,Eden Live objects in will be moved to Survivor District . Continue the cycle , The next time Eden When full Minor GC,Eden and Survivor Each has some surviving objects , If you put Eden The survival objects of the zone are placed in Survivor District , Obviously, the memory occupied by these two parts of objects is not continuous , It also leads to memory fragmentation , Serious impact on system performance .
It makes sense , Two pieces should be built Survivor District , The newly created object is Eden in , Experience once Minor GC,Eden The live object in will be moved to the first piece survivor space S0,Eden Be emptied ; etc. Eden The district is full again , Just trigger it again Minor GC,Eden and S0 The live objects in will be copied to the second block survivor space S1( This process is very important , Because this replication algorithm guarantees S1 From S0 and Eden Two live objects occupy continuous memory space , To avoid fragmentation ).
S0 and Eden Be emptied , And then the next round S0 And S1 Exchange roles , And so on and so on . If the number of copies of an object reaches 16 Time , The object will be sent to the elderly .
The biggest advantage of the above mechanism is , The whole process , There will always be one survivor space It's empty. , The other is not empty survivor space No debris .
Last ad , If you think this article will help you , I can pay attention to my technical official account. 【CodingCode】. Your attention and forwarding is my biggest support ,O(∩_∩)O.
边栏推荐
- version `ZLIB_1.2.9‘ not found (required by /lib64/libpng16.so.16)
- Map data types in golang
- CVPR2022 | 可精简域适应
- CTF steganography
- 持续测试和质量保障的关系
- Messy knowledge points
- How to improve program performance
- "Ai+ education" and "Ai education": one for education and the other for Education
- Is it safe to open an account for shares of tongdaxin?
- GNN上分利器!与其绞尽脑汁炼丹,不如给你的GNN撒点trick吧
猜你喜欢

13 `bs_duixiang.tag标签`得到一个tag对象

GNN upper edge distributor! Instead of trying to refine pills, you might as well give your GNN some tricks

Alibaba interview question: multi thread related

机器学习中 TP FP TN FN的概念

GNN上分利器!与其绞尽脑汁炼丹,不如给你的GNN撒点trick吧

ShardingSphere-proxy-5.0.0容量范围分片的实现(五)

数据管理:业务数据清洗,落地实现方案

Skywalking installation and deployment practice

Perhaps the greatest romance of programmers is to commemorate their dead mother with a software

Everything I see is the category of my precise positioning! Open source of a new method for saliency map visualization
随机推荐
Devops culture: Amazon leadership principles
所见之处都是我精准定位的范畴!显著图可视化新方法开源
【小程序】编译预览小程序时,出现-80063错误提示
Data management: business data cleaning and implementation scheme
Talk to Wu Jiesheng, head of Alibaba cloud storage: my 20 years of data storage (unlimited growth)
One article introduces you to the world of kubernetes
Golang gets the start timestamp and end timestamp of a past or future week or month
GNN上分利器!与其绞尽脑汁炼丹,不如给你的GNN撒点trick吧
7 tips for preventing DDoS Attacks
The Mars rescue plan has been released. The year of the tiger is limited to dolls waiting for you!
【机器学习】线性回归预测
Intelligent + fault-tolerant server is the best partner in the edge computing scenario
Longest substring without duplicate characters
Zhongshanshan: engineers after being blasted will take off | ONEFLOW u
How to quickly convert stock code into int in quantitative trading?
数据管理:业务数据清洗,落地实现方案
2021-11-21: map[i][j] = = 0, which means that (I, J) is an ocean. If you cross it, the cost will be
Open source model library of flying propeller industry: accelerating the development and application of enterprise AI tasks
Is it safe to open a stock account online now? Select a state-owned securities firm, and the fastest time to open an account is 8 minutes
Solve the problem that Base64 compressed files are extracted with spaces after post request