GraalVM Hello World Program Down To "Just" 6.5MB
摘要
GraalVM CE 25.1.3 发布,支持 JIT 编译录制与重放、添加反汇编工具、为不可信代码提供可选常量常数 blinding 支持;新增 Web Image 实验后端(Ahead-of-Time 编译 Java 应用为 WebAssembly 模块并加 JavaScript 包装);对 Native Image 进行进一步压缩,包括堆元数据、模块元数据、运行时动态访问元数据、符号表数据,以及对简单常量 String.format 和 String::formatted 调用进行内联;Linux AMD64 下 Hello World 应用镜像大小降至约 6.5MB,整体镜像大小提升 25.1% vs 25.0.x(约 1-2% 常规增益),RSS 也有正向效果;另有 GraalJS、GraalPy 功能增强,以及其他兼容性与调试改进。
荐读理由
Native Image 现在把 HelloWorld 压缩到 6.5MB(Linux AMD64),通过堆元数据精简、String.format 内联优化就能直接在项目里跑出极小二进制
原文
GraalVM CE 25.1.3 Gets Native Image "Hello World" Program Down To Just 6.5MB
Written by Michael Larabel in Programming on 30 June 2026 at 04:11 PM EDT. 31 Comments

GraalVM, the advanced JDK focused on ahead-of-time (AOT) Native Image compilation and since last year began shifting focus to more non-Java languages like Python and JavaScript, is out with its newest community feature release. GraalVM Community Edition 25.1.3 is now available with some interesting changes in tow.
GraalVM 25.1.3 adds support for recording and replaying JIT compilations with the Graal compiler, a new disassembly tool is added, and there is optional constant blinding support for untrusted code. Plus new performance improvements, debugging enhancements, improved compatibility, Linux builds now producing Position Independent Executables (PIEs) by default, and other enhancements. There is also improved language support for GraalJS as the JavaScript offering, GraalPy for Python adding more features, and more.
GraalVM 25.1.3 also has Web Image as a new experimental back-end for GraalVM Native Image that compiles a Java application ahead-of-time to a WebAssembly module with a JavaScript wrapper.
Catching me most by surprise was a listed change for reducing Native Image sizes by further compacting them:
"Reduced Native Image size by compacting image heap metadata and storage, including module metadata, runtime dynamic-access metadata, and symbol table data, and intrinsifying simple constant String.format and String::formatted calls. This reduces the size of a HelloWorld application on Linux AMD64 to ~6.5 MB."
As in, catching me by surprise that getting a basic "Hello World" program down to ~6.5MB... Perhaps too used to other languages, but a 6.5MB binary for a "Hello World" program?! I was curious how big the HelloWorld AMD64 Linux build was previously, so was digging through the activity. Much of Graal development is behind Oracle's closed doors but this pull request brought up a public question over the impact on size. The additional Native Image compaction in this release "should be around 1-2% image size across the board." And then further elaborated:
"Overall, you will see larger improvements of 25.1 vs 25.0.x in image size, because we did several smaller optimizations in this area (some still pending) that add up. There is also a smaller positive effect on RSS due to the more compact representations. You will see a very large drop in helloworld image size due to the String format intrinsification."
But still, getting a HelloWorld app down to 6.5MB; is it just me or is that still rather bloated for all but the most elaborate "hello world" programs?
Downloads and more details on the GraalVM Community 25.1.3 release can be found via GitHub.
这条对你有帮助吗?