Configure the garbage collector

Garbage collection is performed by a Java process, garbage collection, which removes data that is no longer needed from memory. For the best performance, use either the Garbage-First (G1) or Continuous Mark Sweep (CMS) collector. By default, Hyper-Converged Database (HCD) uses the Garbage-First (G1) collector.

The primary differences between the collector options are:

  • G1 divides the heap into multiple regions, where the number of regions depends primarily on the heap size and heap region size. The G1 collector dynamically assigns the regions to old generation or new generation based on the running workload, prioritizing garbage collection in areas of the heap that will yield the largest free space when collected. Additionally, G1 makes tradeoffs at runtime optimizing for a pause target (which is configurable using -XX:MaxGCPauseMillis) to provide predictable performance.

  • CMS divides the heap into new generation (eden + survivor spaces), old generation, and permanent generation, and relies on many heuristics and configurable settings to optimize for performance.

G1 advantages

DataStax recommends G1 over CMS for the following reasons:

  • G1 supports large heap sizes (24-96 GB) without tuning. HCD systems have enough RAM to run larger heaps.

  • G1 handles dynamic workloads more effectively than CMS. HCD systems typically have multiple workloads, such as reads, writes, compactions, indexing, and range reads.

  • CMS is deprecated in Java 9 (JDK-8142518) and removed in Java 14 (JDK-8229049).

  • G1 is easier to configure. The only configuration options are MAX_HEAP_SIZE and -XX:MaxGCPauseMillis.


Change the Garbage-First MaxGCPauseMillis parameter

Set the peak pause time for the Garbage-First (G1) garbage collector located in jvm11-server.options.

Use the Continuous Mark Sweep (CMS) garbage collector

Change GC from Garbage-First to CMS.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax | Privacy policy | Terms of use | Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com