Java generational thinking and Java generational thinking

Source: Internet
Author: User

Java generational thinking and Java generational thinking

We all know that java gc is based on java's generational premise. Both CMS and G1 are based on the generational thought: the old age and the new generation

Thought 1: Why can we perform generational division?

1. The object lifecycle in java is different. The age concept in gc is involved.

Short-lived objects, such as temporary variables of methods.

Long-lived objects, such as cache objects and connection pools.

2. The reference relationship between a long-lived object and a short-lived object is relatively small (important ).

 

Thinking 2: What are the advantages of generational division?

From the perspective of garbage collection, different collection algorithms can be used for different generations to improve the efficiency of garbage collection and reduce the stw time of the system.

 

Think 3: Do generations have no disadvantages?

Suppose we have a java System in a scenario, which is not in line with the premise of thinking about the java generational division, the generational garbage collection algorithm will affect the system performance. (We look forward to encountering such a system ....)

 

Thinking 4: Just for garbage collection?

As mentioned in the first point, the service is divided into java objects, and java objects are divided into two processes: Allocation and collection. Therefore, we need to combine object allocation and garbage collection to consider generation division, the goal of generation is to increase the efficiency of object allocation and garbage collection.

 

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.