-
Notifications
You must be signed in to change notification settings - Fork 34
feat(java14): add JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AloisSeckar
merged 3 commits into
AloisSeckar:master
from
YuuuuuuYu:yuuuuuuyu/jep-363-demo
Oct 31, 2025
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/org/javademos/java14/jep363/RemoveTheCMSGarbageCollectorDemo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package org.javademos.java14.jep363; | ||
|
|
||
| import org.javademos.commons.IDemo; | ||
|
|
||
| /// Demo for JDK 14 feature JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector. | ||
| /// | ||
| /// JEP history: | ||
| /// - JDK 14: [JEP 363 - Remove the Concurrent Mark Sweep (CMS) Garbage Collector](https://openjdk.org/jeps/363) | ||
| /// - JDK 9: [JEP 291 - Deprecate the Concurrent Mark Sweep (CMS) Garbage Collector](https://openjdk.org/jeps/291) | ||
| /// | ||
| /// @author yuuuuuuyu | ||
|
|
||
| public class RemoveTheCMSGarbageCollectorDemo implements IDemo { | ||
| @Override | ||
| public void demo() { | ||
| info(363); | ||
|
|
||
| // The Concurrent Mark Sweep (CMS) garbage collector was a low-pause GC | ||
| // designed for applications requiring shorter stop-the-world times. | ||
| // It performed part of its mark-and-sweep phases concurrently with | ||
| // running application threads. | ||
| // | ||
| // However, CMS had several drawbacks: | ||
| // - High maintenance cost and complex code base in HotSpot. | ||
| // - Fragmentation issues due to the non-compacting nature of CMS. | ||
| // - Poor scalability and unpredictable long pauses on large heaps. | ||
| // | ||
| // Because modern GCs like G1 (JEP 248), ZGC (JEP 333), and Shenandoah | ||
| // offer better latency and throughput characteristics, | ||
| // CMS was first deprecated in JDK 9 (JEP 291) and completely removed | ||
| // in JDK 14 under JEP 363. | ||
| // | ||
| // As of JDK 14 and later, the JVM ignores the option | ||
| // "-XX:+UseConcMarkSweepGC" and prints a warning message instead: | ||
| // "Ignoring option UseConcMarkSweepGC; support was removed in 14.0" | ||
| // | ||
| // e.g. (jdk 11) `java -XX:+UseConcMarkSweepGC -version` | ||
| // result: | ||
| // OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. | ||
| // openjdk version "11.0.28" 2025-07-15 LTS | ||
| // OpenJDK Runtime Environment Microsoft-11913448 (build 11.0.28+6-LTS) | ||
| // OpenJDK 64-Bit Server VM Microsoft-11913448 (build 11.0.28+6-LTS, mixed mode, sharing) | ||
| // | ||
| // e.g. (jdk 17, 25) `java -XX:+UseConcMarkSweepGC -version` | ||
| // result: | ||
| // Unrecognized VM option 'UseConcMarkSweepGC' | ||
| // Error: Could not create the Java Virtual Machine. | ||
| // Error: A fatal exception has occurred. Program will exit | ||
| // | ||
| // Developers migrating from older Java versions should replace CMS | ||
| // with modern collectors such as: | ||
| // - G1GC (default since JDK 9) | ||
| // - ZGC for ultra-low latency workloads | ||
| // - Shenandoah for concurrent compaction | ||
| // | ||
| // No source-level code changes are required — only JVM options and | ||
| // performance tuning scripts need to be updated when upgrading. | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.