HOME

TheInfoList



OR:

Garbage-First (G1) is a garbage collection
algorithm In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
introduced in the
Oracle An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination. Descript ...
HotSpot
Java virtual machine A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally descr ...
(JVM) 6 Update 14 and supported from 7 Update 4. It was planned to replace concurrent mark sweep collector (CMS) in JVM 7 and was made default in Java 9.


Garbage collector

Garbage-First (G1) collector is a server-style garbage collector, targeted for multiprocessors with large
memories Memory is the faculty of the mind by which data or information is Encoding (memory), encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future Action (philosophy), action. I ...
, that meets a soft real-time goal with high probability, while achieving high-throughput. G1 preferentially collects regions with the least amount of live data, or "garbage first". G1 is the long term replacement of CMS. Whole-heap operations, such as global marking, are performed concurrently with the application threads, to prevent interruptions proportional to heap or live-data size. Concurrent marking provides both collection completeness and identifies regions ripe for reclamation via compacting evacuation. This evacuation is performed in parallel on multiprocessors, to decrease pause times and increase throughput. G1 was first introduced as an experimental option in Java SE 6 Update 14, where it can be enabled with the following two command-line parameters: -XX:+UnlockExperimentalVMOptions and -XX:+UseG1GC With JDK 7, G1 was planned to replace CMS in the Hotspot JVM. There are two major differences between CMS and G1. The first is that G1 is a compacting collector. G1 compacts sufficiently to completely avoid the use of fine-grain free lists for allocation, which considerably simplifies parts of the collector and mostly eliminates potential fragmentation issues. As well as compacting, G1 offers more predictable garbage collection pauses than the CMS collector and allows users to set their desired pause targets. In Java 9 G1 was made the default garbage collector, in spite of
Google Google LLC (, ) is an American multinational corporation and technology company focusing on online advertising, search engine technology, cloud computing, computer software, quantum computing, e-commerce, consumer electronics, and artificial ...
counter proposing the well-known CMS as the standard, claiming the modified CMS it uses performs better than G1. Since then, Oracle has greatly improved G1's throughput, latency and memory footprint.


Related products

Guaranteed real-time behavior even with garbage collection requires a real-time garbage collector such as those that come with Sun's
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
RTS or
IBM International Business Machines Corporation (using the trademark IBM), nicknamed Big Blue, is an American Multinational corporation, multinational technology company headquartered in Armonk, New York, and present in over 175 countries. It is ...
’s WebSphere RT.http://www.ibm.com/developerworks/java/library/j-rtj4/index.html?S_TACT=105AGX02&S_CMP=EDU Real time Garbage Collection


See also

* Mark-compact algorithm


References


External links


HotSpot G1/Parallel/Serial GCs team blog

Garbage-First Garbage collection

How does the Garbage-First Garbage Collector work?

JAVA GARBAGE COLLECTION HANDBOOK G1 – Garbage First

G1: One Garbage Collector To Rule Them All


{{Memory management navbox Memory management algorithms Automatic memory management Java virtual machine