Java Virtual Machine-garbage collection algorithm, java garbage collection

Source: Internet
Author: User

Java Virtual Machine-garbage collection algorithm, java garbage collection

This article mainly introduces the garbage collection algorithm of Java virtual machine.

I. Overview

Ii. Mark-clear Algorithm

Mark-Sweep. Like the name, the algorithm is divided into two steps:

Disadvantages:

Iii. replication algorithm

The replication algorithm is an optimization of tag clearing. It divides the memory on the heap into two areas of equal size, one is the idle area and the other is the active area. In the running of the program, the actual use is the activity area, that is, 50% of the space is wasted.

Implementation process:

Advantage: After memory is recycled, there will be a large partContinuous.

Disadvantage: 50% of the memory space is stored. GC only Uses idle areas when memory is recycled.

Iv. tagging-Sorting Algorithm

The tag operation is consistent with the "tag-clear" algorithm. Subsequent operations not only clean up objects directly, but move all surviving objects to one end after useless objects are cleared, update the pointer of the referenced object.

Main disadvantage: objects need to be moved on the basis of tag-clearing, and the cost is relatively high. The advantage is that memory fragments are not generated.

V. Generational Collection Algorithms

Divide java heap into the new generation and old generation:

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.