Usage:
This flag allows you to use the parallel old Garbage Collector.
Since:
Starting from JDK 6.
Deprecated:
- Deprecated in JDK14
- Obsoleted in JDK15
- Expired in JDK16
Examples:
This will instruct JVM to enable the use of parallel old Garbage Collector:
-XX:+UseParallelOldGC
Description:
Before talking about the flag, we need to introduce Garbage Collector (GC), Young and Old Generations:
Garbage Collector is a way of the JVM to clean the memory and makes the java memory more efficient. It tracks (Mark step) and removes (sweep step) every unused object available in the JVM heap space. An object is considered unused when it’s referenced by null, assigned to another reference or by anonymous object …. There are 5 type of GC implementations:
- Serial Garbage Collector
- Parallel Garbage Collector
- CMS Garbage Collector
- G1 Garbage Collector
- Z Garbage Collector
Young Generation is a place where all new objects start out and aged. It’s divided into two spaces:
- Eden Space: New object initiated with the keyword “new” are allocated in this memory space.
- Survivor Space: When the Eden space is filled. A minor garbage collection event occurs. Objects that are referenced are marked and some are not. The ones which are marked will move to Survivor Space S0 and the one unmarked are removed by GC. When The space S0 filled, the cycle repeat itself but instead of moving them to S0, they will be moved to Survivor Space S1.
Old Generation is a place where objects that lived for a long time lie. If an object reaches an age threshold after surviving multiple GC events in the Young Generation, the object gets moved to the Old Generation.
Thus, JVM introduced many flags to interact with GC, one of them is “UseParallelGC”. This flag enables/disables GC the use of Mark and Compact algorithm in Old Generation. It allows the GC to use multiple threads while executing a major collection by using the algorithm Mark and Compact. This will allow the minor collection to be done in multiple threads and major collections in a single thread.
Default Value:
By default, this flag is disabled.
Note:
Enabling it automatically enables the -XX:+UseParallelGC option.
Arguments related:
InitialSurvivorRatio, UseParallelGC
Related Posts:
Edit your Comment