Hitachi

uCosminexus Application Server System Design Guide


7.15.7 GC implemented by G1 GC

There are three types of GC executed by generational GC under the G1 GC technique.

  1. Young GC

    GC that applies to the New area. The types of young GC are young GC (normal), and young GC (initial-mark) in which marking is performed as part of young GC. For details, see 7.15.8 Young GC. If the term young GC is used along, the matter being described relates to both young GC (normal), and young GC (initial-mark). The suffixes (normal) and (initial-mark) are used when there is a need to distinguish between young GC (normal) and young GC (initial-mark). For young GC (normal), log data is output to the log file with YoungGC specified as the GC type. Young GC occurs when the creation of a Java object causes the Eden area to run out of space.

  2. Mixed GC

    GC that applies to the New area and the Tenured area. Mixed GC applies selectively to Tenured regions depending on the target pause time. For details, see 7.15.10 Mixed GC. Like young GC, mixed GC occurs when the creation of a Java object causes the Eden area to run out of space, but can also be triggered by the results of analysis called Concurrent Marking that determines whether objects are in use. For details, see 7.15.9 Concurrent Marking (CM). If analysis is lacking or the analysis results predict that mixed GC would not be very effective, young GC (normal) is triggered instead.

  3. Full GC

    GC that applies to all areas in the JavaVM including the Tenured area, Metaspace area, and Humongous area. For details, see 7.15.11 Full GC. Full GC is triggered when there are no more Free regions available to be allocated to the Tenured area, Metaspace area, or Humongous area.

The following figure summarizes the areas targeted by each GC method.

Figure 7‒25: Areas targeted by each GC method

[Figure]

The following figure shows the status transitions undergone by each GC method.

Figure 7‒26: Status transitions of each GC method

[Figure]

  1. After young GC (normal) is executed, if Concurrent Marking (CM) has not been executed and usage of the Tenured area exceeds 45% of the Java heap area, the status transitions to one in which young GC (initial-mark) is executed the next time GC occurs.

  2. After young GC (normal) is executed, if Concurrent Marking (CM) has not been executed and usage of the Tenured area does not exceed 45% of the Java heap area, the status remains unchanged and young GC (normal) is executed the next time GC occurs.

  3. After young GC (initial-mark) is executed, the status transitions to one in which young GC (normal) and CM are executed in parallel the next time GC occurs.

  4. While CM is being executed, the status remains one in which young GC (normal) will be executed.

  5. If the predicted collection rate of young GC (normal) immediately after CM finishes exceeds 10%, the status transitions to one in which mixed GC is executed the next time GC occurs.

  6. If the predicted collection rate is 10% or less, the status remains unchanged and young GC (normal) is executed the next time GC occurs

  7. After mixed GC is executed, if the predicted collection rate exceeds 10%, the status remains unchanged and mixed GC is executed the next time GC occurs.

  8. After mixed GC is executed, if the predicted collection rate is 10% or less, the status changes and young GC (normal) is executed the next time GC occurs.

Note that in the following circumstances, the applicable GC method will be implemented when the conditions are met regardless of the GC status.

The following explains G1 GC processing using the example of a Java object.

Figure 7‒27: Flow of G1 GC

[Figure]

  1. Young GC

    As shown in the preceding figure, young GC is triggered when there are no longer any empty regions allocated to the New area. Young GC moves in-use objects to the regions allocated to the Survivor area, and releases used objects at the region level. Like the copy GC method of serial GC, objects that are in use when young GC occurs move back and forth between the regions allocated to the Survivor area. After moving a certain number of times, these objects are moved to a region allocated to the Tenured area. After young GC, the system estimates the time required for the next GC based on how long GC took, and resizes the New area accordingly. In the example in the preceding figure, the New area is reduced in size because GC took longer than the estimated time.

  2. Mixed GC

    Mixed GC is triggered when the usage of the Tenured area increases. In addition to the regions allocated to the New area, mixed GC targets some of the regions allocated to the Tenured area as the target pause time permits. GC prioritizes those regions allocated to the Tenured area that would free the most space based on analysis of which objects are in use conducted in parallel with the application. If analysis has not been performed to a sufficient level or the analysis results predict that mixed GC would not be very effective, then mixed GC is not triggered.

  3. Full GC

    If there are no more empty regions in the Java heap and mixed GC is not triggered, then Full GC occurs for the entire Java heap.