2.9.2 Processing flow of GC control
GC control is processed as shown in the following figure.
|
|
-
Monitoring memory
Monitoring timer thread monitors memory of JavaVM. The GC control functionality is requested to perform GC when certain conditions are met. For the conditions, see section (1) shown later.
-
Checking resource exclusion
When requested to perform GC, the GC control functionality checks whether excluded resources exist.
-
Placing Full GC in a wait state
Full GC is placed in a wait state while resources are excluded.
-
Performing Full GC
When the resources are not excluded, Full GC starts.
The following subsections describe each process:
- Organization of this subsection
(1) Monitoring memory
The monitoring timer thread monitors the memory used by the Java VM and, when any of the following conditions are met, requests the GC control functionality to perform GC:
- If serial GC is enabled:
-
-
Size of the used Tenured area / Size of the entire Tenured area × 100 ≥ GC control threshold value
-
Size of the entire New area / Maximum size of free Tenured area × 100 ≥ GC control threshold value
-
Size of the used Metaspace area / Maximum size of the Metaspace area × 100 ≥ GC control threshold value
-
- If G1 GC is enabled:
-
-
Size of the used Java heap area / Size of the entire Java heap area × 100 ≥ GC control threshold value
-
Size of the used Metaspace area / Maximum size of the Metaspace area × 100 ≥ GC control threshold value
-
(2) Checking resource exclusion
When requested to perform GC, the GC control functionality runs a check on the connections used by the batch application. When checking the connections, the functionality confirms whether the batch application is performing resource exclusion.
The following table describes states considered as the resources are in exclusion.
|
Transaction |
State |
DB Connector |
JDBC |
|
|---|---|---|---|---|
|
Out of transaction |
Executing SQL statement#1 |
|
Y |
N |
|
Performing operations for ResultSet |
|
Y |
N |
|
|
Performing operation such as object acquisition#1 |
|
Y |
N |
|
|
During transaction |
|
Y |
N |
|
|
When executing global transaction (JTA) |
-- |
-- |
||
Legend: Y: Handled as resource under exclusion
N: Handled as resource not under exclusion
--: Not applicable
#1: java.sql.Statement in the table -includes sub-interfaces java.sql.PreparedStatement and java.sql.CallableStatement.
#2: Shows a status after starting a transaction (after executing setAutoCommit(false) or UserTransaction.begin), in which execution of SQL statement or operation for ResultSet is performed one or more times, and transaction conclusion processing is not complete.
Resource operations performed by using JDBC are handled as no resource exclusion. For example, if you execute a program that includes execution of SQL statements for JDBC and transaction processing in DB Connector, only the transaction processing in DB Connector is subject to GC control.
(3) Placing Full GC in a wait state
If the functionality judges that excluded resources exist, it outputs the KDJE55024-I message and places Full GC in a wait state. Full GC continues to wait while there is at least one excluded resource. The following figure shows an example case where Full GC is placed in a wait state.
|
|
In this figure, two resources are accessed in a single job program. If the GC control functionality is requested to perform Full GC while resources are excluded, the functionality places Full GC in a wait state. When con2.commit() that ends the access of two resources is executed, the exclusion is removed.
(4) Performing GC
When no resources are excluded, the functionality performs Full GC.
(5) Notes
-
You can concurrently execute only one batch application.
-
You can execute processing to multiple resources from one batch application. However, you cannot use global transactions.
-
Even when Full GC is placed in a wait state, the Java VM might perform Full GC if free memory becomes insufficient. This is likely to occur when a large threshold value is set for the memory usage during GC or when resources are excluded for a long time. To prevent this, tune the threshold values related to memory usage. For details about how to tune the threshold values, see 9.4 Setting the thresholds for GC control in the uCosminexus Application Server System Design Guide.