ParallelOld collector for JAVA Garbage Collector
The Parallel Old collector is a type of Garbage Collector in Java virtual machines. Like the Serial Old collector, it worked in the Old era of JAV virtual machines. This type of Garbage Collector uses multithreading and the "tag-sort" algorithm. It is available only in JDK 1.6.
You can prioritize Parallel Scavenge and Parallel Old collectors when you focus on throughput and CPU resource sensitivity.
1. Run the code
Package com. gc;
Import java. util. ArrayList;
Import java. util. List;
/**
* Simple memory recovery for Java virtual machines and use of the parallel old collector
* Parameter:-Xms30m-Xmx60m-Xmn10m-XX: + UseParallelOldGC-XX: + PrintGCDetails
* @ Author fan fangming
*/
Public class EasyParallelOld {
Public byte [] placeHolder = new byte [64*1024]; // placeHolder
Public static voidmain (String [] args) throws Exception {
OutOfMemoryByExpansionSize ();
}
Private static voidoutOfMemoryByExpansionSize () throws Exception {
List <EasyParallelOld> list = new ArrayList <EasyParallelOld> ();
While (true ){
EasyParallelOldserial = new EasyParallelOld ();
List. add (serial );
Thread. sleep (10); // pause for 10 ms
}
}
}
2. Parameters
-Xms30m-Xmx60m-Xmn10m-XX: + UseParallelOldGC-XX: + PrintGCDetails
-Xms30m JVM minimum 30 M
-Xmx100m JVM max 100 M
-The new generation of Xmn10m is fixed to 10 M.
-XX: + UseParallelOldGC corresponds to parallel scavenge + parallel old collector
-XX: + PrintGCDetails print detailed GC
3. Running result
...
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 50664 K-> 50664 K (51200 K)] 54058 K-> 54058 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0043610 secs] [Times: user = 0.00 sys = 0.00, real = 0.00 secs]
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 50728 K-> 50728 K (51200 K)] 54122 K-> 54122 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0071480 secs] [Times: user = 0.00 sys = 0.00, real = 0.01 secs]
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 50792 K-> 50792 K (51200 K)] 54186 K-> 54186 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0061676 secs] [Times: user = 0.00 sys = 0.00, real = 0.01 secs]
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 50856 K-> 50856 K (51200 K)] 54250 K-> 54250 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0047575 secs] [Times: user = 0.00 sys = 0.00, real = 0.00 secs]
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 50920 K-> 50920 K (51200 K)] 54314 K-> 54314 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0044603 secs] [Times: user = 0.00 sys = 0.00, real = 0.00 secs]
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 50984 K-> 50984 K (51200 K)] 54378 K-> 54378 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0041311 secs] [Times: user = 0.00 sys = 0.00, real = 0.00 secs]
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 51048 K-> 51048 K (51200 K)] 54442 K-> 54442 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0042710 secs] [Times: user = 0.00 sys = 0.00, real = 0.00 secs]
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 51112 K-> 51112 K (51200 K)] 54506 K-> 54506 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0044147 secs] [Times: user = 0.00 sys = 0.00, real = 0.00 secs]
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 51176 K-> 51176 K (51200 K)] 54570 K-> 54570 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0044082 secs] [Times: user = 0.00 sys = 0.00, real = 0.00 secs]
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 51176 K-> 51176 K (51200 K)] 54570 K-> 54570 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0044738 secs] [Times: user = 0.00 sys = 0.00, real = 0.01 secs]
Exception in thread "main" java. lang. OutOfMemoryError: Java heap space
Atcom. gc. EasyParNew. <init> (EasyParNew. java: 12)
Atcom. gc. EasyParNew. outOfMemoryByExpansionSize (EasyParNew. java: 39)
Atcom. gc. EasyParNew. main (EasyParNew. java: 14)
Heap
PSYoungGen total 6848 K, used 3456 K [0x0ad30000, 0x0b730000, 0x0b730000)
Eden space 3456 K, 100% used [0x0ad30000, 0x0b090000, 0x0b090000)
From space 3392 K, 0% used [0x0b090000, 0x0b090000, 0x0b3e0000)
To space 3392 K, 0% used [0x0b3e0000, 0x0b3e0000, 0x0b730000)
ParOldGen total 51200 K, used 51176 K [0x07b30000, 0x0ad30000, 0x0ad30000)
Object space 51200 K, 99% used [0x07b30000, 0x0ad2a0a0, 0x0ad30000)
PSPermGen total 12288 K, used 2105 K [0x03b30000, 0x04730000, 0x07b30000)
Object space 12288 K, 17% used [0x03b30000, 0x03d3e4a8, 0x04730000)
4. differences with the serial Old collector
The serial Old collector is a serial garbage collection, while the Parallel old collector is a Parallel garbage collection.
[Full GC [PSYoungGen: 3394 K-> 3394 K (6848 K)] [ParOldGen: 51048 K-> 51048 K (51200 K)] 54442 K-> 54442 K (58048 K) [PSPermGen: 2084 K-> 2084 K (12288 K)], 0.0042710 secs] [Times: user = 0.00 sys = 0.00, real = 0.00 secs]
And
[GC [DefNew: 9108 K-> 966 K (9216 K), 0.0049332 secs] [Tenured: 46824 K-> 46893 K (46920 K ), 0.0033687 secs] 47800 K-> 47790 K (56136 K), [Perm: 2086 K-> 2086 K (12288 K)], 0.0084489 secs] [Times: user = 0.02 sys = 0.00, real = 0.01 secs]
ParOldGen indicates that Parallel old is recycled in the old age;
Tenured indicates that serial old is recycled in the old age.