Search code examples
javagarbage-collectiongraalvm

Garbage collector is not supported by Graal


I am trying to run a Java program on GraalVM Community Edition 1.0 RC4 , the code works with last JDK 8 version. The code runs the same way with GraalVM but the same error message is printed in the console 100 times per second (I think every time that the garbage collector is needed/used) :

org.graalvm.compiler.debug.GraalError: <unknown> garbage collector is not supported by Graal
at org.graalvm.compiler.hotspot.HotSpotGraalRuntime.<init>(HotSpotGraalRuntime.java:205)
at org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:145)
at org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:123)
at org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:47)
at jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.getCompiler(HotSpotJVMCIRuntime.java:360)
at jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.compileMethod(HotSpotJVMCIRuntime.java:448)

The program seems to be slowed down by the prints and/or by the possible absence of garbage collection and it never ends.

I made a test with a simple HelloWorld and the same error message keeps showing up. The program ends, since it's short enough, and it compiles.

I followed the tutorial on the official site with the GraalVM Community Edition. I found a similar error on Graal Github, but I can't figure out how to set the Garbage Collector, the command lines used seem to be Java 10 exclusive.

EDIT and Solution : I am using an Oracle VM VirtualBox on Ubuntu, it seems that the VM setting were too low. If you are encountering the same problem, increase your RAM and CPUs, it should solve it.


Solution

  • According to the Github issue you linked, this is an issue when the compiler is initialized before the selected GC is reflected in the flags. This seems to happen on machines that HotSpot does not consider server-class, in which case it actually defaults to the serial GC.

    You should be able to work around it by explicitly requesting the serial GC with -XX:+UseSerialGC.