Garbage collection algorithm of Java Virtual machine

Source: Internet
Author: User

tag-purge algorithm:This is the most basic, is the previous two times the mark, first mark out all the objects that need to be recycled, and then do a unified cleanup,This has two drawbacks: one is inefficient, marking and purging (turning on low priority for recycling) is inefficient. The second is the space problem, where tag cleanup generates a lot of memory fragmentation.  Replication algorithm:you can divide the memory into two blocks of equal size, using only one block at a time, and when a fast memory is exhausted, move the surviving object to another piece,The used piece is then recycled with the garbage collector. This is a simple and efficient way to operate. The disadvantage is that the actual usage size of the memory is reduced. For example, using 20M of memory, you can only use 10M each time. and in the case where the object is more alive, it is necessary to perform more replication operations, and the efficiency will be reduced.  tag-Collation algorithm:The tagging process is still the same as the mark-sweep algorithm, where objects are organized and all objects are moved to the net, and then the memory outside the end boundary is cleaned up directly . Generational collection algorithm:Modern commercial virtual machines mostly use the generational collection algorithm, which divides the memory into different blocks depending on the life cycle of the object.in general, the Java heap is divided into the new generation and the old age, in the new generation of garbage collection every time the discovery of a large number of objects died,only a small amount of survival, and then select the replication algorithm, so that only a small number of objects to survive the cost of replication can be done to complete the collection,in the old age, because of the high survival rate of the object, there is no additional space to guarantee it, you must use the tag-cleanup algorithm to reclaim   

Garbage collection algorithm of Java Virtual machine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.