Java thousands of questions _07JVM Architecture (009) _ What is the new generation of replication algorithm __ encoding

Source: Internet
Author: User
Tags garbage collection

Click to enter _ more _java thousand ask 1, what is the new generation of replication algorithm

Understanding heap Memory Look here: What is the Java heap memory
Learn about Java garbage collection look here: What is the Java garbage collection mechanism
The so-called replication algorithm (copying), the memory will be divided into a zone, b area two, replication + garbage removal operations, the algorithm is illustrated as follows:

Algorithm procedure: The new object is allocated to unused memory in block a. When block A's memory is used up, copy a block's surviving object to block B. Clears all objects of block A. The newborn object is allocated to unused memory in block B. When block B's memory is used up, copy the live object of Block B to block a. Clears all objects of block B. Cycle 1.

This algorithm is simple and efficient, but the memory cost is very high, the effective memory is only half of the total memory, will waste 50% of the space. So this algorithm is only paper algorithm, not available, generally use the optimized replication algorithm. 2, what is the optimization of the replication algorithm

The so-called optimized replication algorithm, which is based on the replication algorithm, uses three partitions (EDEN/S0/S1) for processing, the algorithm is illustrated as follows:

The EDEN/S0/S1 default space scale Eden:S0:S1 is 8:1:1, and effective memory (which allocates the memory of the newborn object) is 90% of the total memory.

Algorithm process: EDEN+S0 can allocate the new object, Eden+s0 garbage collection, and the surviving object is copied to S1. Clean the EDEN+S0. A new generation of GC ends. EDEN+S1 can be assigned to new objects, garbage collection for Eden+s1, and live objects replicated to S0. Clean the EDEN+S1. Two Cenozoic GC end. Cycle 1.

We can see that if the proportion of the eden/s0/s1 three spaces is 8:1:1, then there may be 10% (S1, S0 space in total space of 10%) in the EDEN+S0 where the surviving object exceeds the total space, in which case the Cenozoic GC will put the long-lived objects directly into the older generation Without having to reach the threshold we set (the number of surviving generations,-xx:maxtenuringthreshold).

Of course, this will not happen normally (unless there is a special scenario, or a programming problem). IBM's research has shown that 98% of the new generation of objects are dying in the face of death, so the proportion of 8:1:1 is very reasonable. (The free memory space in the new generation is 90% of the total Cenozoic capacity (80%+10%), and only 10% of the memory is wasted).

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.