GC: serial, parallel, concurrent collector

Garbage collector (GC, garbage collector) (automatic memory management system (automatic storage management system)) Categories:
(1) serial (Serial) Collector :
1> Using a single-threaded process all garbage collection work, because no interaction multithreading , it is more efficient. However, you can not use the advantage of multiple processors, so this collection is suitable for single-processor machine. Of course, this collector may be used in a small amount of data (about 100M) conditions on multiprocessor machines. You can use -XX: + UseSerialGC open.
(2) Parallel (Parallel) Collector :
1> for the young generation parallel garbage collection, the garbage collection time can be reduced. In general multi-threaded multiprocessor using the machine. Use - XX: + UseParallelGC open.
2> use - XX: ParallelGCThreads = <N> number of threads in parallel garbage collection. This value can be set equal to the number of machine processors.
3> maximum garbage collection pause : the longest pause time garbage collection specified by -XX: Specifies MaxGCPauseMillis = <N>. <N> ms. If this value is specified, then the garbage collection heap size, and parameters are adjusted to the specified value. Set this value may reduce throughput applications.
4> Throughput: Garbage collection time and the throughput of the non-time garbage collection ratio, by -XX: setting GCTimeRatio = <N>, formula 1 / (1 + N). For example, -XX: GCTimeRatio = 19, it means that 5% of the time for garbage collection. Default is 99, i.e., 1% of the time for garbage collection.
(3) concurrent (Concurrent) collector (concurrent mark clearance (Concurrent Mark Sweep) Collector) :
1> can ensure that most of the work carried out concurrently (the application does not stop), garbage collection pause only very little time, this collector suitable relatively high, the large-scale application response time requirements. Use -XX: + UseConcMarkSweepGC open.
2> concurrent collector is mainly to reduce the old generation of suspended time, he uses a separate garbage collection thread in the case of the application does not stop, track up to object. In each old generation garbage collection cycle, a brief pause at the beginning of the concurrent collector will collect the entire application, the collection will be suspended once again. Second pause will be slightly longer than the first time, multiple threads at the same time garbage collection work in the process.
3> concurrent collector uses processor time in exchange for a brief pause. On a system of N processors, using concurrent collection portion K / N processors are available for recycling, in general, 1 <= K <= N / 4.
4> using only concurrent collector on a host processor, the mode is set to incremental mode a short dwell time can be obtained.
5> Floating garbage : Because garbage collection while the application is running, so some garbage may be generated when garbage collection is completed, thus causing the "Floating Garbage", these need to recycle garbage out on the next garbage collection cycle. Therefore, concurrent collector typically require 20% to reserve space for the floating garbage.
6> Concurrent Mode Failure : concurrent collector application running in the collection, so it is necessary to ensure that garbage collection heap at this time there is enough space for the program, otherwise, garbage collection has not been completed, the first full heap space. Will happen "concurrent mode failure" In this case, the entire application will be suspended at this time, garbage collection.
7> Start concurrent collector: Because the application runs concurrent collection in the collection, it is necessary to ensure that there is enough memory space used by the program before the collection is completed, there would be "Concurrent Mode Failure". By providing -XX: CMSInitiatingOccupancyFraction = <N> Specifies the concurrent collection started when there is much remaining stack

Serial processor:
applies: The
amount of data is small (about 100M); and no application response time requirements of a single processor.
Disadvantages: it can only be used for small applications

Parallel processor:
applicable: "
high throughput requirements ", the CPU plurality, the response time of the application No, the large-scale application. Example: background processing, scientific computing.
Disadvantages: application response time may be longer

Processor Concurrency:
applicable: "
There are high demands on response time ", the CPU plurality, there are, the high requirements for large applications application response time. For example: Web server / application server, telecommunications switching, integrated development environment.

Reference: https: //blog.csdn.net/lantian0802/article/details/39226525

The new generation of objects in the young generation, is still alive after N GC into the old generation. Static fields, methods, inner classes on the permanent generation.
Reference: https: //blog.csdn.net/kidoo1012/article/details/54599046

Guess you like

Origin blog.csdn.net/haoranhaoshi/article/details/94620409