Can't use Shenandoah GC

4.2k Views Asked by At

I can't put ShenandoahGC to work while trying to run a Java application. Regardless of what I try, the output is as follows, when invoking the java command from Terminal (or CMD):

Error occurred during initialization of VM

Option -XX:+UseShenandoahGC not supported

Running openJDK version 15.0.2 on Ubuntu (WSL) and on Windows, I get the same message on both.

Have tried applying the -XX:+UnlockExperimentalVMOptions option next to -XX:+UseShenandoahGC, but as far as I know the experimental status was dropped with JDK 15.

3

There are 3 best solutions below

1
On BEST ANSWER

From what I have read here: What is new in Java 15 (point 10. JEP 379) Shenandoah GC is not included in official OpenJDK 15 release.

0
On

The short answer is that Oracle Java and the OpenJDK Java builds available from the official OpenJDK download site DO NOT include support for the Shenandoah GC.

But the good news that many other Java 12+ builds do. AdoptOpenJDK does. RHEL's Java does. Ubuntu's Java (installed from the package manager) does. And I expect others do as well.


This situation is explained in an article on Red Hat's blog, excerpted below.

"Not all OpenJDK 12 builds include Shenandoah: Here's why"

Dated: April 19, 2019

[...]

A little history: Shenandoah, a high-performance low-pause-time garbage collector, is a Red Hat-led project. When we first proposed to contribute Shenandoah to OpenJDK, Oracle made it clear that they didn't want to support it. That's fair enough: OpenJDK is free software, so you don't have to support anything you don't want. We told Oracle that we'd work with them to design a really clean pluggable garbage-collector interface that allows anyone easily to select the garbage collectors to include in their builds. We did that together, and Shenandoah went in to JDK 12.

Evidently Oracle has chosen not to build Shenandoah. They aren't doing anything strictly wrong by excluding it, but something doesn't feel right to me. These builds aren't supported by Oracle—you need their commercial binaries to get support—so why exclude Shenandoah? It might simply be that they used their standard build scripts to build their open source binaries. However, in a rather feature-light OpenJDK release, I find it odd for open source builds to exclude one of the most significant contributions. I really appreciate Oracle providing GPL-licensed OpenJDK builds, but I wish they'd build all of it.

[...]

Note that the commentary in the above is not mine, but that of the author of the blog posting.

3
On

I wish I had an answer for getting a good reliable JVM with Shenandoah enabled, but I've run into similar issues. But just to point out the benefit of Shenandoah.

I'm running a very simple program, but very big. I need between 300-400GB of RAM to run my program. The program is little more than a couple of large array lists and a couple of large ConcurrentHashMaps. I have about 700 million objects that I need to put into those lists and maps. So when I simply measure the load time of this data on any JDK 1.8-1.19 without Shenandoah, ie g1gc, it takes about 40 minutes and all 32 cores are 90% busy, much of it in the kernel. This is running on Windows Server 2012 R2. By only changing the garbage collector to Shenandoah that time drops to 35 seconds. With only 1 core busy. That's a huge improvement. The JDK that I found with Shenandoah support was:

openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment Temurin-16.0.2+7 (build 16.0.2+7)
OpenJDK 64-Bit Server VM Temurin-16.0.2+7 (build 16.0.2+7, mixed mode, sharing)

The downside is that after loading my data, I populate additional maps of similar size using ForkJoin pools with between 8 and 32 threads and run some RegEx's, but I can repeatedly crash the JVM. I don't know if this is due to something I've done wrong, the fork join pools, garbage collector, or the OpenJDK. But I'd love to find a production hardened JDK with Shenandoah.