Garbage-First Collector
Introduction
The Garbage-First (G1) garbage collector is fully supported in Oracle JDK 7 update 4 and later releases. The G1 collector is a server-style garbage collector, targeted for multi-processor machines with large memories. It meets garbage collection (GC) pause time goals with high probability, while achieving high throughput. Whole-heap operations, such as global marking, are performed concurrently with the application threads. This prevents interruptions proportional to heap or live-data size.
Technical description
The G1 collector achieves high performance and pause time goals through several techniques.
The heap is partitioned into a set of equal-sized heap regions, each a contiguous range of virtual memory. G1 performs a concurrent global marking phase to determine the liveness of objects throughout the heap. After the mark phase completes, G1 knows which regions are mostly empty. It collects in these regions first, which usually yields a large amount of free space. This is why this method of garbage collection is called Garbage-First. As the name suggests, G1 concentrates its collection and compaction activity on the areas of the heap that are likely to be full of reclaimable objects, that is, garbage. G1 uses a pause prediction model to meet a user-defined pause time target and selects the number of regions to collect based on the specified pause time target.
The regions identified by G1 as ripe for reclamation are garbage collected using evacuation. G1 copies objects from one or more regions of the heap to a single region on the heap, and in the process both compacts and frees up memory. This evacuation is performed in parallel on multi-processors, to decrease pause times and increase throughput. Thus, with each garbage collection, G1 continuously works to reduce fragmentation, working within the user defined pause times. This is beyond the capability of both the previous methods. CMS (Concurrent Mark Sweep ) garbage collection does not do compaction. ParallelOld garbage collection performs only whole-heap compaction, which results in considerable pause times.
It is important to note that G1 is not a real-time collector. It meets the set pause time target with high probability but not absolute certainty. Based on data from previous collections, G1 does an estimate of how many regions can be collected within the user specified target time. Thus, the collector has a reasonably accurate model of the cost of collecting the regions, and it uses this model to determine which and how many regions to collect while staying within the pause time target.
Recommended Use Cases for G1
The first focus of G1 is to provide a solution for users running applications that require large heaps with limited GC latency. This means heap sizes of around 6GB or larger, and stable and predictable pause time below 0.5 seconds.
Applications running today with either the CMS or the ParallelOld garbage collector would benefit switching to G1 if the application has one or more of the following traits.
- More than 50% of the Java heap is occupied with live data.
- The rate of object allocation rate or promotion varies significantly.
- Undesired long garbage collection or compaction pauses (longer than 0.5 to 1 second)
Future
G1 is planned as the long term replacement for the Concurrent Mark-Sweep Collector (CMS). Comparing G1 with CMS, there are differences that make G1 a better solution. One difference is that G1 is a compacting collector. G1 compacts sufficiently to completely avoid the use of fine-grained free lists for allocation, and instead relies on regions. This considerably simplifies parts of the collector, and mostly eliminates potential fragmentation issues. Also, G1 offers more predictable garbage collection pauses than the CMS collector, and allows users to specify desired pause targets.
original article : http://docs.oracle.com/javase/7/docs/technotes/guides/vm/G1.html
相关推荐
Garbage-First is a server-style garbage collector, targeted for multi-processors with large memories, that meets a soft real-time goal with high probability, while achieving high throughput. Whole-...
G1垃圾回收器论文。 Garbage-First Garbage Collection October 24-25, 2004
The Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide describes the garbage collection methods included in the Java HotSpot Virtual Machine (Java HotSpot VM) and ...
G1垃圾收集器的总体流程与重要算法
JDK12-hotspot-virtual-machine-garbage-collection-tuning-guide
JDK15-hotspot-virtual-machine-garbage-collection-tuning-guide
JDK11-hotspot-virtual-machine-garbage-collection-tuning-guide
JDK16-hotspot-virtual-machine-garbage-collection-tuning-guide
JDK17-hotspot-virtual-machine-garbage-collection-tuning-guide
JDK18-hotspot-virtual-machine-garbage-collection-tuning-guide
JDK19-hotspot-virtual-machine-garbage-collection-tuning-guide
garbage-classification-master.zip
jdk20-hotspot-virtual-machine-garbage-collection-tuning-guide Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide-58
十分丰富的垃圾分类数据集,有json格式和csv格式
InfoQ的关于JVM GC的学习资料,对于深入学习JVM的GC机制很有帮助
系统级编程的课程实验,实现内存的的自动回收管理。 这里需要声明的是,资源不是来自本人,资源来自网络。本着造福广大学生的目的。但是本人实在太菜,不知道如何设置资源分数为0,所以就设置为1. ...
Garbage classification is a scientific management method for effective garbage disposal. It helps people maximize the utilization of waste resources and prevent deteriorating environmental conditions ...
项目4:标记清除垃圾收集的模拟结果到期日:18/05/20,星期日,晚上11点。逾期的项目将不被接受。 该项目的目的是通过在涉及BST的源程序中进行模拟,以更好地理解标记清除垃圾收集,如课程注释12中所述。...
libunwind - a platform-independent unwind library.FIXME for AArch64.