How to Replace the Deprecated CMS GC in JDK 9?
This article explains why the CMS garbage collector was removed in JDK 9, shows the deprecation warning, and evaluates three migration paths—switching to G1 GC, adopting ZGC, or continuing with CMS—helping developers choose the best option for their applications.
In JDK 9 the Concurrent Mark Sweep (CMS) garbage collector was deprecated, as described in JEP‑291, to reduce maintenance complexity and accelerate new GC features.
If you start an application with the -XX:+UseConcMarkSweepGC flag, the JVM prints the following warning:
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.Why was CMS GC deprecated?
CMS is a highly configurable and complex algorithm, which adds significant code complexity to the JDK’s GC subsystem. Simplifying the GC codebase allows the JDK team to innovate faster. The table below shows that CMS has 72 extra JVM options, far more than any other collector.
What to do if you are using CMS?
There are three main options:
Switch to the G1 GC algorithm, which became the default in Java 9 and generally offers better performance with fewer tuning parameters.
Switch to ZGC (available in early versions of JDK 11 and 12), a low‑latency collector targeting pause times under 10 ms.
Continue using CMS, which can still outperform G1 for certain workloads after careful tuning; the community even debates keeping CMS available.
Conclusion
Each application is unique, so thorough testing and benchmarking of any new GC configuration are essential before making a decision.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
