Announcing GraalVM for JDK 23

The Graal team is pleased to announce the general availability of Oracle GraalVM for JDK 23. In addition to JDK 23 support, this release includes many enhancements to Native Image ahead-of-time compilation to tune a generated executable’s size, memory usage, and throughput. This release is also the first with production support for embedding Python and WebAssembly in Java with full JIT compilation for excellent performance.

Native Image

Oracle GraalVM for JDK 23 adds a new option for minimizing the size of compiled executables as well as improvement to the Serial garbage collector to support memory constrained applications.

Optimizing for Size

When compiling application to native machine code, the level of code optimization can be controlled with the -O command line option with values ranging from 0 (zero, no optimizations) to 3 (all available optimizations).  Applying fewer optimizations means faster build times, but potentially slower performance. More optimizations may also mean larger executables, due in part to code inlining.

There are also some special optimization levels like -Ob (quick build) which speeds up builds by avoiding some time-consuming optimizations. The generated executables may also be a little larger so this option is not recommended for production deployment, but it is great during development when build time is more important than throughput and size.

In the JDK 23 release, Oracle GraalVM adds the new -Os optimization level that minimizes the size of the generated executable by skipping specific optimizations that increase code size. This level can be useful when deploying applications in container or on small devices that have limited disk space.

You can learn more in Native Image Optimization Levels.

Optimizing for Memory Usage

To support different use cases, Oracle GraalVM Native Image supports three garbage collection implementations:

  • G1 GC–a low latency garbage collector for applications with larger heaps
  • Epsilon GC–which doesn?t actually collect any garbage but may be useful in short lived applications like command line utilities
  • Serial GC–which is suitable for applications with small heaps

In GraalVM for JDK 23, Serial GC has been enhanced with an experimental mark and compact collector option that further reduces the total amount of memory required by an application (i.e., maximum RSS). This new collector can reduce GC memory overhead by 50%. Serial GC with the new mark and compact collector is ideal for applications deployed in containers where memory is limited. To enable, add the -H:+CompactingOldGen option when using the native-image utility to generate an executable.

Python and WebAssembly

Since it launched in 2019, Oracle GraalVM has included support for GraalJS, an ECMAScript compliant JavaScript implementation. With GraalJS, it is possible to embed and call JavaScript modules from Java applications. In the Oracle GraalVM for JDK 23 release, GraalJS is joined by GraalPy and GraalWasm for Python and WebAssembly (WASM) embedding, respectively.

GraalPy makes it possible to leverage popular Python packages, including for machine learning, in Java applications. GraalWasm provides similar embedding support for WebAssembly. With GraalWasm it is possible to integrate and call C, C++, Rust, Go, and many other language libraries compiled to WASM. While WebAssembly is still an evolving standard, GraalWasm offers excellent feature support.

And thanks to GraalVM?s advanced compiler technology, JavaScript, Python, and WASM are all dynamically compiled by the Graal JIT compiler to native machine code ensuring excellent performance and interoperability with Java.

Learn More

For technical details on the Oracle GraalVM for JDK 23 release, checkout the developer blog, the release notes, and the documentation.

To stay informed on the latest news you can follow GraalVM on X(Twitter) and LinkedIn.

Oracle GraalVM is included in the Oracle Java SE Subscription and is available at no additional cost for use on Oracle Cloud Infrastructure. Download the latest release today!