GC 4-differences between minor GC, Major GC, and full GC

Source: Internet
Author: User

For the implementation of hotspot Vm, there are only two types of GC in it:

  • Partial GC: does not collect the entire GC heap Mode
    • Young GC: Only GC of young gen is collected.
    • Old GC: Only GC of Old Gen is collected. Only the concurrent collection of CMS is in this mode.
    • Mixed GC: Collect GC of the entire young Gen and some old Gen. Only G1 has this mode.
  • Full GC: Collects the entire heap, including the mode of young Gen, Old Gen, Perm Gen (if any) and all parts.

Major GC is usually equivalent to full GC and collects the entire GC heap. However, since hotspot VM has been developing for so many years, the external interpretations of various terms are completely confusing, when someone says "Major GC", be sure to ask whether it refers to the above full GC or Old Gen.

The simplest generational GC strategy depends on the implementation of the hotspot VM's serial GC. The trigger conditions are as follows:

  • Young GC: triggered when the Eden area in young gen is fully allocated. Note that some surviving objects in young GC are promoted to Old Gen, so the usage of Old Gen usually increases after young GC.
  • Full GC: when preparing to trigger a young GC, if statistics are found that the average promotion size of young GC is larger than the remaining space of Old Gen, this will not trigger young GC, but will trigger full GC (because in the GC of the hotspot Vm, except the concurrent collection of CMS, the GC that can collect the Old Gen will collect the entire GC heap at the same time, including young Gen, so you do not need to trigger a separate young GC); or, if perm Gen exists, you need to allocate space while perm Gen does not have enough space, it also needs to trigger a full GC; or system. GC () and heap dump with GC. By default, full GC is triggered.

Other non-concurrent GC trigger conditions in the hotspot VM are more complex, but the general principle is the same as that mentioned above. Of course, there are always exceptions. In the parallel scavenge (-XX: + useparallelgc) framework, the young GC is executed one time before the full GC is triggered by default, and the application can run a little less between the two GC, in order to reduce the pause time for full GC (because young GC will try to clean up dead objects of young Gen and reduce the workload of full GC ). This is a wonderful thing in the hotspot VM. The trigger conditions for concurrent GC are not the same. Taking cms gc as an example, it mainly checks the usage of Old Gen regularly. When the usage exceeds the trigger ratio, a cms gc is started and the Old Gen is collected concurrently.

GC 4-differences between minor GC, Major GC, and full 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.