JVM Garbage Collection algorithm

Source: Internet
Author: User

Mark-Clear

The mark-and-sweep algorithm is the basic idea of modern garbage collection algorithm. The tag-purge algorithm divides garbage collection into two phases: the tagging phase and the purge phase. A feasible implementation is to mark all the objects that can be reached from the root node, first through the root node, in the tagging phase. Therefore, an object that is not marked is a garbage object that is not referenced. Then, in the purge phase, clear all unmarked objects

Mark-Organize

According to the characteristics of the old age, the marker-collation algorithm is presented. It does some optimizations based on the mark-and-sweep algorithm. Like the mark-and-sweep algorithm, the tag-grooming algorithm first needs to start with the root node and mark all objects that can be reached. However, it does not simply clean up unmarked objects, but instead compresses all the surviving objects to one end of the memory. After that, clean up all the space outside the boundary.

Replication Algorithms

New Generation recovery algorithm. Divide the original memory space into three pieces, a larger Eden Space and two smaller survivor space. Use Eden and a piece of survivor each time. Copies the surviving object to another survivor space when the object is recycled. If there is not enough space, go straight to the old age.

Generational thinking

According to the survival period of the object, the short-lived object is classified as the new generation and the long-life object belongs to the old age.

According to the characteristics of different generations, select the appropriate collection algorithm

Few objects survive, suitable for replication algorithms

Large number of objects survive, suitable for tag cleanup or tag compression

Stop-the-world

A phenomenon of global pauses in Java

Global pause, all Java code stops, native code can execute, but cannot interact with JVM

Mostly due to GC

Dump thread

Deadlock Check

Heap Dump

Procedures continue to run the garbage produced, we all have to stop, and so collect, we continue to work. Let everyone stop, long time will certainly be uncomfortable.

JVM Garbage Collection algorithm

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.