Three GC-related three-minute recognition of GC algorithms

Source: Internet
Author: User

The GC algorithm evolved slowly, evolving into the current generational GC. Its evolutionary process labeling-clearing algorithm –> tag-copy algorithm –> marker-collation algorithm –> the generational algorithm.

Before we introduce the algorithm, we know that Java is dynamic loading. Its characteristics:

1. Hierarchical relationship, by Bootstrap class loader–> Extension class loader, System class loader (APP class loader), User Defin Ed Class Loader.

2. Delegate load mode, load a class, first see whether the parent class has been loaded, only the parent class cannot load, the subclass will try to load, which ensures that the application is loading the same class (the same code).

3. To make the class have restrictions, the parent class cannot access the class that the child class loads, and the subclass can use the class that the parent class loads.

4. Although the load class cannot unload its loaded class, it can delete the current load class.

Through the dynamic loading mechanism of Java, we can know that a live object in Java can be traced from the root (the topmost loading class). To understand this, let's go back to the specific GC algorithm.

Tag-Purge algorithm:

By marking the objects that can be traced back, and then deleting the objects that are not marked. The disadvantage of this algorithm is that it can cause memory fragmentation.

Tag-Copy algorithm:

Divide the memory into two, delete unmarked objects, and then copy the tagged objects to another. This algorithm avoids the memory fragmentation problem, but it brings a memory waste problem (half of memory space-time).

Tag-Collation algorithm:

This algorithm removes unmarked objects and then organizes the tagged objects into memory. This algorithm avoids the defects of the first two algorithms, but it brings the problem of inefficiency.

Split-generation algorithm:

This algorithm can be based on the needs of the application algorithm selection and parameter adjustment, the next section we will talk about the GC parameter adjustment.

Three GC-related three-minute recognition of GC algorithms

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.