In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Analysis of JVM garbage Collection algorithm
Mark-clear algorithm
This algorithm is the most basic algorithm. It is divided into two stages: marking and clearing. First, the objects that need to be recycled are marked, and after the marking is finished, the objects are recycled uniformly. There are two problems in the algorithm: one is efficiency, the efficiency of marking and cleaning process is not too high, and the other is space problem. After performing a clean operation, there will be a lot of discontinuous memory fragments, resulting in a waste of resources. Too much space debris will cause that failure to find enough contiguous memory when large objects need to be allocated while the program is running will lead to the next garbage collection operation.
Replication algorithm
The algorithm is based on the mark-erase algorithm, which is mainly to improve efficiency. It divides the memory area into two equal blocks, using only one of them at a time. When one piece is used up, the surviving object is moved to another block, and then the memory occupied by the existing object is freed. This only releases one of the memory, and there is no problem of memory fragmentation. But the efficiency of this algorithm is based on the premise that the memory is reduced to 50% of the original, and it is obtained by exchanging space for space.
Marking-finishing algorithm
There is a problem with the replication algorithm, when the object survival rate is high, it will copy frequently, which will also lead to inefficiency. The marking-finishing algorithm appears on the basis of the first two algorithms, and its marking process is the same as that of the marking-clearing algorithm, except that it does not recycle recyclable objects, but moves all surviving objects to a test, and then clears the memory beyond the boundary.
Generation collection algorithm
At present, the garbage collection of commercial virtual machines adopts a generation-by-generation collection algorithm, which divides memory into several parts according to the life cycle of objects. It is generally divided into the new generation and the old generation. In the new generation, if a large number of objects are found to die and a small number of objects survive, the replication algorithm is used to complete this garbage collection at the expense of a small amount of replication cost, while the older generation can complete this garbage collection because of the object survival rate. There is no extra space to guarantee it, and it is generally processed using a mark-clear algorithm or a mark-collation algorithm.
Author: Ke Zhimeng
Source: CSDN
Original: https://blog.csdn.net/yin4302008/article/details/85997091
Copyright notice: this article is the original article of the blogger, please attach a link to the blog article to reprint it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.