Let's write a HelloEpsilon class and execute it using Epsilon GC. Here's the sample code:
class HelloEpsilonGC { public static void main(String[] args) { System.out.println("Hello to Epsilon GC!"); } }
To execute the preceding code using Epsilon GC, you must use the -XX:+UnlockExperimentalVMOptions option with the -XX:+UseEpsilonGC option, followed by the class to execute:
>java -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC
HelloEpsilonGC
The following screenshot highlights the preceding command at the top; the remaining part includes the GC output:
As highlighted in the preceding screenshot, the following describes the GC output:
- JVM uses the Epsilon GC
- It outputs the Hello to Epsilon GC! string to the standard output
- It includes just one allocation of 792 KB
Recently, I was delivering a session on Java 11 features, and one of the attendees had a query. He asked:
I think this is an important question. Often, we don't care about the details until we need them.
If you know the answer, this question might seem trivial to you. If not, let's answer this simple and important question in the next section.