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-...
为了推动这一进程,研究人员和开发者们制作了一系列的数据集,其中,“garbage-classification-data-master_futurevnm_garbage-master_生活垃圾”是一个极具价值的资源,它提供了丰富的垃圾分类数据,旨在助力AI技术...
G1垃圾收集器的总体流程与重要算法
garbage-classification-master.zip
《garbage-root:一款综合性的垃圾分类与识别小程序详解》 在当今社会,环保意识日益增强,垃圾分类成为我们生活中的重要一环。为了更好地推动垃圾分类工作,开发者推出了一款名为"garbage-root"的小程序,它集成了...
4. Garbage-First(G1)垃圾收集器:G1垃圾收集器是Java 7中引入的新型垃圾收集器,使用增量式标记-清除算法。 5. Z垃圾收集器(Z Garbage Collector):Z垃圾收集器是Java 11中引入的低延迟垃圾收集器,使用增量式...
标题 "102-garbage-after-endif.rar_after" 暗示了这是一个关于修复或更新某个代码库的压缩文件,可能是一个补丁或者更新版本。描述中提到的 "libunwind" 是一个重要的线索,这是一款跨平台的展开库,用于在运行时...
4. **垃圾收集器类型**:HotSpot提供了多种GC策略,如Serial GC、Parallel GC、Parallel Old GC、CMS(Concurrent Mark Sweep)、G1(Garbage-First)和ZGC(Zing Concurrent Low Latency Collector)。每种收集器有...
Python实时垃圾分类系统(环境教程&完整源码&数据集)_real-time-garbage-classification-python
HotSpot 虚拟机中的垃圾收集机制可以分为两种:Serial Garbage Collector 和 Parallel Garbage Collector。Serial Garbage Collector 是一种 serial 模式的垃圾收集器,适用于小型应用程序。Parallel Garbage ...
垃圾回收(Garbage Collection,简称GC)是Java语言的一个重要特性,它自动化地管理程序中的内存分配与释放,避免了传统C++等语言中的内存泄漏问题。本文将围绕Java垃圾回收这一主题,展开一系列关键知识点的详细解析...
用于人工智能学习所实验的智能垃圾分类系统_garbage-classification
4. **G1垃圾收集器(G1 Garbage Collector)**:G1是一种新生代和老年代都进行并发收集的垃圾收集器,目标是实现可预测的暂停时间模型。G1会将堆划分为多个区域,并尝试预测和控制每次GC的暂停时间。 在选择垃圾...
HotSpot 虚拟机采用了 Generational Garbage Collection(分代垃圾回收)机制,即将 Java 对象分为年轻代、老年代和永久代三个部分。年轻代存储着刚刚创建的对象,老年代存储着长期存活的对象,而永久代则存储着类、...
系统级编程的课程实验,实现内存的的自动回收管理。 这里需要声明的是,资源不是来自本人,资源来自网络。本着造福广大学生的目的。但是本人实在太菜,不知道如何设置资源分数为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 ...
垃圾回收(Garbage Collection)是 Java 虚拟机(JVM)中的一种机制,旨在自动管理 Java 对象的生命周期,避免内存泄露和溢出。垃圾回收器会周期性地扫描 Java 堆,标记并清除不再使用的对象,从而释放内存空间。 ...