The principle of Java GC

Source: Internet
Author: User

Java GC (Garbage Collec, garbage collection, recycling)

GC is the memory in the JVM is marked and recycled, Sun's JDK virtual machine is a hotspot object of the instance is placed in the heap heap memory, where the generational collection is also referred to the heap memory of garbage collection of GC is divided into: young generation, the old age, the permanent generation. (The method area is treated as a permanent generation, but will be canceled after JDK1.6) younger generation (young Generation), older generation (old Generation), permanent generation (Permanent Generation, which is the method area) 1. Young generation of GC (storing instantiated objects) The young generation is divided into three zones: Eden and two surviving zones (Survivor0 and Survivor1), respectively, 80%, 10%, 10% of memory, using stop-copy (stop-and-copy) Cleanup (Copy the Eden area and an object that is still alive in the survivor to another survivor) when the Eden is full, the MINORGC is executed once and the remaining surviving objects are added to the Surivivor0. Reclaim objects that are not alive in Eden. When the Surivivor0 page is full, it will still be saved to Surivivor1, and the objects Surivivor0 and Surivivor1 in the Surivivor0 are saved sequentially, when the two survival zones have been switched several times (the hotspot defaults to 15), Copy the surviving objects to the old age 2. GC of the old age (storing large instanced objects and surviving long enough in young generations) The old GC used a marker-collation algorithm, which marked the surviving object, moved toward one end, guaranteed the integrity of the memory, and then cleared the unmarked out when the old age was not enough. Also executes the major GC, which is full GC Note: If the constants and classes stored on permanent generations are too large to be put into permanent generations, they will also trigger a permanent generation of GC, which will be part of the old age 3. GC for permanent generation (storing constants, Class) Description: After the JDK1.6 version, the permanent generation will be canceled, leaving only the young generation and the old age description: The young generation of GC is necessary, but the old and the permanent generation is not necessary, you can set parameters to decide whether to recycle the class is a picture of the picture below.

The principle of Java GC

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.