当前位置:网站首页>Deep understanding of JVM (V) - garbage collection (II)
Deep understanding of JVM (V) - garbage collection (II)
2022-06-30 18:03:00 【Zhaoliwen is a pig】
In depth understanding of JVM( 5、 ... and )—— Garbage collection ( Two )
List of articles
2、 Garbage collection algorithm
Mark - eliminate

Definition : As the name suggests , It refers to the process of garbage collection in the virtual machine , Firstly, the recyclable object is determined by marking algorithm , Then the garbage collector clears the corresponding content according to the identification , Make room for heap memory
- Freeing up memory space here does not clear bytes of memory space 0, Instead, record the start and end address of this memory , The next time you allocate memory , Will directly Cover This memory
shortcoming : It is easy to produce a large number of memory fragments , May not be able to meet the memory allocation of large objects , Once the object cannot be allocated , That would lead to jvm start-up gc, Once started gc, Our application will pause , This causes the response speed of the application to slow down
Mark - Arrangement

Mark - Arrangement Will not be GC Root Referenced object recycling , Know the memory space it occupies . Then sort out the remaining objects , It can effectively avoid problems caused by memory fragmentation , But because the whole takes some time , So it's less efficient
Copy




Divide the memory into two areas of equal size ,FROM and TO(TO Empty in middle ). First will be GC Root The referenced object is from FROM Put in TO in , Recycling is not GC Root Referenced object . Then exchange FROM and TO. This can also avoid the problem of memory fragmentation , But it takes up double the memory space .
3、 Generational recycling

Recycling process
The newly created objects are placed in The new generation of Eden in

When there is not enough memory in the garden of Eden , There will be a garbage collection , The recycling at this time is called Minor GC
Minor GC Will The garden of Eden and the survival zone FROM Living objects First Copied to the Survival zone TO in , And let it Life plus 1, Again Swap two surviving areas



Create the object again , If the new generation of Eden is full again , will Trigger again Minor GC( Will trigger stop the world, Pause other user threads , Just let the garbage collection thread work ), At this time, we will not only recycle the garbage in the garden of Eden , And recycle the garbage in the surviving areas , Then copy the active object to the surviving area TO in . After recycling, two surviving areas will be exchanged , And let the objects in the surviving area Life plus 1

If the object in the surviving area Life exceeds a certain threshold ( The maximum is 15,4bit), Will be Put in the older generation in

If the memory of the new generation and the old generation is full , It will trigger first Minor GC, Trigger again Full GC, scanning In the new generation and the old generation All objects that are no longer in use and recycle
GC analysis
Large object processing strategy
When I meet a A larger object when , Even the new generation The garden of Eden It's empty , also The object cannot be accommodated when , The object will be Directly promoted to the elderly generation
Thread memory overflow
A thread's memory overflowed and threw an exception (out of memory), Won't let other threads end
This is because when a thread Throw out OOM After abnormality , All the memory resources it occupies will be released , This will not affect the operation of other threads , The process is still normal
边栏推荐
- Daily interview 1 question - basic interview question of blue team - emergency response (1) basic idea process of emergency response +windows intrusion screening idea
- [sword finger offer] 52 The first common node of two linked lists
- Parker variable displacement piston pump pv092r1k1t1nmmc
- [zero basic IOT pwn] environment construction
- 如何写一个技术方案
- New research of HKUST & MsrA: about image to image conversion, finishing is all you need
- Thinking on large file processing (upload, download)
- MSF后渗透总结
- Exch:exchange server 2013 is about to end support
- K-line diagram must be read for quick start
猜你喜欢

5g has been in business for three years. Where will innovation go in the future?

Post penetration file system + uploading and downloading files

Advanced Mathematics (Seventh Edition) Tongji University General exercises one person solution

同济、阿里的CVPR 2022最佳学生论文奖研究了什么?这是一作的解读

MIT科技评论2022年35岁以下创新者名单发布,含AlphaFold作者等

Inventory in the first half of 2022: summary of major updates and technical points of 20+ mainstream databases

Course design for the end of the semester: product sales management system based on SSM

Nft: unlimited possibilities to open the era of encryption Art

Cloud practice of key business migration of Internet of things by well-known Internet housing rental service companies

New skill: accelerate node through code cache JS startup
随机推荐
送受伤婴儿紧急就医,滴滴司机连闯五个红灯
流批一体在京东的探索与实践
Generate confrontation network, from dcgan to stylegan, pixel2pixel, face generation and image translation.
[sword finger offer] 53 - I. find the number I in the sorted array
IEEE TBD SCI影响因子提升至4.271,位列Q1区!
广电5G正式启航,黄金频段将如何应用引关注
应届生毕业之后先就业还是先择业?
[BJDCTF2020]The mystery of ip|[CISCN2019 华东南赛区]Web11|SSTI注入
分享 5 大常用的特征选择方法,机器学习入门必看!!!
生成对抗网络,从DCGAN到StyleGAN、pixel2pixel,人脸生成和图像翻译。
ABAP-发布Restful服务
【机器学习】K-means聚类分析
Parker Parker sensor p8s-grflx
Vue3 reactive database
Shortcut keys for the rainbow brackets plug-in
Course design for the end of the semester: product sales management system based on SSM
.NET ORM框架HiSql实战-第一章-集成HiSql
Building a basic buildreoot file system
【网易云信】播放demo构建:无法将参数 1 从“AsyncModalRunner *”转换为“std::nullptr_t”**
How can you choose to work in the county after graduation?