当前位置:网站首页>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.
边栏推荐
- S2b2c e-commerce platform in the pharmaceutical and medical industry enables enterprises to grasp differentiated competitive advantages and improve supply chain efficiency
- 2021-11-18: given a length len, it indicates how many bits there are in total. All characters
- [technical grass planting] deploy a super large capacity and unlimited speed network disk in Tencent cloud
- Relationship between continuous testing and quality assurance
- Selenium crawls stocks in practice
- Cvpr2022 𞓜 thin domain adaptation
- 用一个软件纪念自己故去的母亲,这或许才是程序员最大的浪漫吧
- Kubernetes' ci/cd practice based on Jenkins spinnaker - adding product image scanning
- November 20, 2021: the start and end times of a movie can be listed in a small array
- Installation and use of winscp and putty
猜你喜欢
![[shutter] how to use shutter packages and plug-ins](/img/a6/e494dcdb2d3830b6d6c24d0ee05af2.png)
[shutter] how to use shutter packages and plug-ins

WinSCP和PuTTY的安装和使用

Error reported using worker: uncaught domexception: failed to construct 'worker': script at***

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

13 `bs_ duixiang. Tag tag ` get a tag object

用一个软件纪念自己故去的母亲,这或许才是程序员最大的浪漫吧

skywalking 安装部署实践

WinSCP和PuTTY的安装和使用
Talk to Wu Jiesheng, head of Alibaba cloud storage: my 20 years of data storage (unlimited growth)

一次 MySQL 误操作导致的事故,「高可用」都顶不住了!
随机推荐
Devops culture: Amazon leadership principles
GNN upper edge distributor! Instead of trying to refine pills, you might as well give your GNN some tricks
Cross domain and jsonp
How to use IOT gateway to realize networking communication of smart road lamp posts
Why traifik ingress?
Local cache selection (guava/caffeine/ohc) and performance comparison
用一个软件纪念自己故去的母亲,这或许才是程序员最大的浪漫吧
Zhongshanshan: engineers after being blasted will take off | ONEFLOW u
[technical grass planting] use webhook to automatically deploy my blogs on multiple sites in Tencent cloud
Ctfhub miscellaneous --icmp
ICML'22 | ProGCL: 重新思考图对比学习中的难样本挖掘
[redis advanced ziplist] if someone asks you what is a compressed list? Please dump this article directly to him.
ShardingSphere-proxy-5.0.0容量范围分片的实现(五)
Dart series: creating a library package
js输入输出语句,变量
Attack and defense world PyC trade
ctfhub---SSRF
Data management: business data cleaning and implementation scheme
跨域和JSONP
"Ai+ education" and "Ai education": one for education and the other for Education