在进行了大量搜查和研究之后,我的理解是:
<>-XX:+UseParallelGC 这使GC得以在Young Generation上使用 多射线,但用于旧的/受限的代谢(<>Serial Mark and Compact的算法。
<>-XX:+UseParallelOldGC 这使GC能够使用Parallel Mark和B算法,载于old/tenured生成。
让我们理解——
计算法和记忆安排,如标记和拷贝、互换空间,在Young Generation上运行,并不奏效。 由于许多原因,老一代<>
Low mortality - In the Old Generation, the "mortality rate" is significantly lower than the same in the Young Generation. In a Typical Java application most objects die quickly and few live longer. As the objects which survive in young generation and promoted to old generation, it is observed that these objects tend to live a longer life. Which leads to very less mortality rate in old generation compared to young generation.
Significantly size - The Old Generation is significantly larger than the Young Generation. Because the Young Generation quickly clears up, relatively little space is available for the many short-lived objects (small Young Generation). In the Old Generation, objects accumulate over time. Therefore, there must be much more space in an old generation than in the Young Generation (big old generation)
Little allocation - In the Old Generation less allocation happens than in the Young Generation. This is because in the Old Generation objects arise only when the Garbage Collector promotes surviving objects from the Young to the Old Generation. In the Young Generation, on the other hand, all the objects that the application generates with new, i.e the majority of the allocations, occur in the Young Generation.
Taking these differences into account, an algorithm has been chosen for the Young Generation that will finish garbage collection as soon as possible, because it has to be called often because of the high mortality rate [point (1)]. In addition, the algorithm must ensure that the most efficient possible memory allocation [point (3)] is then possible because much is allocated in the Young Generation. The mark-and-copy algorithm on the Young Generation has these properties.
On the other hand, this algorithm does not make sense on the Old Generation. The situation is different: the garbage collector has to take care of many objects in the Old Generation [point (2)] and most of them are still alive; only a small part has become unreachable and can be released [point (1)]. If the garbage collector were to copy all the surviving objects on each garbage collection, just as it does with mark-and-copy, then it would spend a lot of time copying it without gaining much.
Therefore, the mark-and-sweep algorithm is made on the old generation, where nothing is copied, but simply the unreachable objects are released. Since this algorithm leads to the fragmentation of the heap, one has additionally considered a variation of the mark-and-sweep algorithm, in which, following the sweep phase, a compaction is made, by which the fragmentation is reduced. This algorithm is called a mark-and-compact algorithm.
A mark and compact algorithm can be time consuming as it needs to traverse the object graph in following for stages.
- Marking.
- Calculation of new locations.
- Reference adjustments.
- Moving
In the Calculation of new location phase, when ever it gets a free space, tries to find an object which can move to this space(defragmentation). Stores the the pair for use in later phases. This causes the algorithm consume more time.
虽然标志和比较解决了与使用权生成相关的某些问题,但这是一个严重的问题,因为这是一个STW活动,耗费了大量时间,可能会严重影响应用。
www.un.org/Depts/DGACM/index_spanish.htm 旧的替代算法
为了减少休息时间,考虑了序列标识和复合算法的替代品:
www.un.org/Depts/DGACM/index_spanish.htm 一种平行的标记和复合式算法,仍然将所有应用线束起来,但随后与多种垃圾收集器相联。 虽然这仍然是一种停止使用的世界办法,但由此造成的停用在多芯或多处理器机上的时间比序列标记和复合算法短。 自Java 5 更新6以来,这一关于“老一代”的平行算法(所谓的“ParallelOld”)已经提供,并选择了-XX:+ UseParallelOldGC。
A competing mark-and-sweep algorithm that at least partially rivals the application without stopping its threads, and occasionally needs short stop-the-world phases. This concurrent mark-and-sweep algorithm (called "CMS") has been around since Java 1.4.1; it is switched on with the option -XX:+UseConcMarkSweepGC. Importantly, this is just a mark-and-sweep algorithm; Compaction does not take place, leading to the already discussed problem of fragmentation.
因此,在“-XX:+ UseParallelOldGC中,作为使用多个透镜的标志,同时使用Mark和《契约算法》进行重大收集。 如果使用这种方法,未成年人或青少年的收集工作是并行的,但主要收集工作仍然只读一次。
我希望这一答复。