The principle of allocation of Java objects in heap memory

Source: Internet
Author: User

1. The object is assigned first in the Eden area, and the virtual machine performs a minor GC once if there is not enough space in the Eden area.


2, large objects directly into the old age (large object refers to the need for a large number of contiguous memory space objects). The purpose of this is to avoid the Eden area and two

A large number of memory copies occur between the survivor regions (the Cenozoic uses a replication algorithm to collect memory).


3, long-term survival of the object into the old age. The virtual machine defines an age counter for each object, and if the object passes through 1 minor GC then the object will enter the Survivor area, then each time after the minor GC so the object's age plus 1, know to reach the threshold object into the old age area.


4, the age of the dynamic judgment object. If the sum of all objects of the same age in the survivor area is greater than half the size of survivor space, objects older than or equal to that age can enter the old age directly.


5, Space allocation guarantee. Each time the minor GC is performed, the JVM calculates the average size of the objects moved to the old age area of the survivor area, and if the value is greater than the remaining value of the old age area, a full GC is performed, and if it is less than the check handlepromotionfailure setting, If true, only the monitor GC is performed, and if False the full GC is performed.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The principle of allocation of Java objects in heap memory

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.