1.serial/serial old
The serial/serial old collector is the most basic and oldest collector, which is a single-threaded collector and must suspend all user threads when it is garbage collected. Serial Collector is for the new generation of collectors, the use of the copying algorithm, Serial old collector is a collector for the older era, using the mark-compact algorithm. Its advantages are simple and efficient, but the disadvantage is that it will bring a pause to the user.
2.ParNew
The Parnew Collector is a multithreaded version of the serial collector that uses multiple threads for garbage collection.
3.Parallel Scavenge
The Parallel scavenge collector is a new generation of multi-threaded collectors (parallel collectors) that do not need to pause other user threads during recycling, using the copying algorithm, which differs from the first two collectors, primarily to achieve a manageable throughput.
4.Parallel old
Parallel old is the older version of the Parallel scavenge collector (parallel collector), using multithreading and Mark-compact algorithms.
5.CMS
The CMS (current Mark Sweep) collector is a collector that targets the shortest payback time and is a concurrent collector, using the mark-sweep algorithm.
6.g1
The G1 collector is the forefront of today's collector technology, a collector for service-side applications that leverages multi-CPU, multicore environments. So it is a parallel and concurrent collector, and it can build a predictable pause-time model.
Let's add something about memory allocation:
The memory allocation of the object, which is allocated on the heap in the general direction, is mainly allocated to the new generation of Eden space and from space, and in rare cases it is directly allocated in the old age. If there is not enough space in the new generation of Eden space and from space, a GC is initiated, and if a GC is made, Eden space and from space can hold the object in Eden space and from space. During GC, the surviving objects in Eden Space and from space are moved to space, and then the Eden space and from space are cleaned. If the to space is not sufficient to store an object during the cleanup process, the object is moved to the old age. After the GC is performed, Eden Space and to space are used, and the next GC will replicate the surviving object to the from Space, so that it loops back and forth. When an object escapes a GC in the Survivor area, its object age increases by 1, and by default, if the object reaches 15 years old, it will move to the old age.
A typical garbage collector