The garbage-first collector (G1) is a
garbage collection
Waste collection is a part of the process of waste management. It is the transfer of solid waste from the point of use and disposal to the point of treatment or landfill. Waste collection also includes the curbside collection of recyclable ...
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
introduced in the
Oracle
An oracle is a person or agency considered to provide wise and insightful counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. As such, it is a form of divination.
Description
The wor ...
HotSpot
Hotspot, Hot Spot or Hot spot may refer to:
Places
* Hot Spot, Kentucky, a community in the United States
Arts, entertainment, and media Fictional entities
* Hot Spot (comics), a name for the DC Comics character Isaiah Crockett
* Hot Spot (Tra ...
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 describ ...
(JVM)
6 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
multiprocessor
Multiprocessing is the use of two or more central processing units (CPUs) within a single computer system. The term also refers to the ability of a system to support more than one processor or the ability to allocate tasks between them. There ar ...
s with large
memories
Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembered, ...
, that meets a soft
real-time
Real-time or real time describes various operations in computing or other processes that must guarantee response times within a specified time (deadline), usually a relatively short time. A real-time process is generally one that happens in defined ...
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
thread
Thread may refer to:
Objects
* Thread (yarn), a kind of thin yarn used for sewing
** Thread (unit of measurement), a cotton yarn measure
* Screw thread, a helical ridge on a cylindrical fastener
Arts and entertainment
* ''Thread'' (film), 2016 ...
s, 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
Java Platform, Standard Edition (Java SE) is a computing platform for development and deployment of portable code for desktop and server environments. Java SE was formerly known as Java 2 Platform, Standard Edition (J2SE).
The platform uses J ...
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
Fragmentation or fragmented may refer to:
Computers
* Fragmentation (computing), a phenomenon of computer storage
* File system fragmentation, the tendency of a file system to lay out the contents of files non-continuously
* Fragmented distributi ...
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
The Java language has undergone several changes since JDK 1.0 as well as numerous additions of classes and packages to the standard library. Since J2SE 1.4, the evolution of the Java language has been governed by the Java Communit ...
G1 was made the default garbage collector,
in spite of
Google
Google LLC () is an American Multinational corporation, multinational technology company focusing on Search Engine, search engine technology, online advertising, cloud computing, software, computer software, quantum computing, e-commerce, ar ...
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 (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
RTS or
IBM’s
WebSphere
IBM WebSphere refers to a brand of proprietary computer software products in the genre of enterprise software known as "application and integration middleware". These software products are used by end-users to create and integrate applications w ...
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
Garbage-First Garbage collectionHow does the Garbage-First Garbage Collector work?JAVA GARBAGE COLLECTION HANDBOOK G1 – Garbage FirstG1: One Garbage Collector To Rule Them All
{{Memory management navbox
Memory management algorithms
Automatic memory management
Java virtual machine