Default Garbage Collector for Java 8

Sheeraz Gul Sep 14, 2022
Default Garbage Collector for Java 8

This tutorial demonstrates the default garbage collector in Java 8.

Default Garbage Collector for Java 8

Different Java versions have different default Java Garbage Collectors. For example:

  1. The default Garbage Collector for Java 7 is Parallel GC.
  2. The default Garbage Collector for Java 8 is Parallel GC.
  3. The default Garbage Collector for Java 9 is G1 GC.
  4. The default Garbage Collector for Java 10 is G1 GC.

The default garbage collector for Java 8 is the Parallel Garbage Collector. The Parallel collector is also known as the Throughput collector.

The Parallel Garbage Collector is considered as same as the serial garbage collector because it will also freeze the running threads of the application when the garbage collection is performed.

The only difference is that parallel garbage collector will use multiple threads for the garbage collection.

The main advantage of using a default garbage collector is that we can assign a few attributes to the garbage collection. For example:

  1. The number of threads the garbage collector can use to perform the garbage collection. The command to perform this GC operation is:

    java -XX:+UseParallelGC -XX:ParallelGCThreads=Number_of_Threads -jar Delftstack.java
    
  2. The time for maximum pause can be assigned for the garbage collection. The command to perform this GC operation is:

    java -XX:+UseParallelGC -XX:MaxGCPauseMillis=Time_In_Millisecond -jar Delftstack.java
    
Author: Sheeraz Gul
Sheeraz Gul avatar Sheeraz Gul avatar

Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.

LinkedIn Facebook

Related Article - Java Garbage Collection