The Serial Garbage Collector


Introduction

The serial collector uses a single thread to perform all garbage collection work, which makes it relatively efficient because there is no communication overhead between threads.

It is best-suited to single processor machines because it can’t take advantage of multiprocessor hardware, although it can be useful on multiprocessors for applications with small data sets (up to approximately 100 MB). The serial garbage collector was designed for applications with small data sets, and its default parameters were chosen to be effective for most small applications.

The serial collector is selected by default on certain hardware (single-CPU systems) and operating system configurations, or can be explicitly enabled with the option -XX:+UseSerialGC.


Serial versus Parallel Collector

The parallel collector, also known as throughput collector, is a generational collector similar to the serial collector. The primary difference between the serial and parallel collectors is that the parallel collector has multiple threads that are used to speed up garbage collection.

On a host with one processor, the parallel collector will likely not perform as well as the serial collector because of the overhead required for parallel execution (for example, synchronization). However, when running applications with medium-sized to large-sized heaps, it generally outperforms the serial collector by a modest amount on computers with two processors, and usually performs significantly better than the serial collector when more than two processors are available.


Further Reading

If you are interested in learning more about how the serial collector works, the introductory and background material in the JDK 8 HotSpot Virtual Machine Garbage Collection Tuning Guide is primarily in reference to the serial collector.


Last reviewed on Sat Feb 01 2025 00:00:00 GMT+0000 (Coordinated Universal Time)