Getting started with the HelloEpsilon GC class

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
The literal meaning of Epsilon is an arbitrarily small amount. This aligns with its op-code.

Recently, I was delivering a session on Java 11 features, and one of the attendees had a query. He asked:

I understand that Epsilon GC doesn't garbage collect the Java heap, but does it garbage collect the stack memory?

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.167.195