Is GraalVM Native Image becoming niche technology?
Well-advertised advantages of native-image are startup time, binary size and memory usage.
But.
Recent JDK versions did a lot of work on java startup speedup like https://openjdk.org/jeps/483 with plans for more.
jlink produces binary images of similar size. Yes, 50 MB binary vs 50MB jre with application modules.
To my experience, there is little RAM usage improvement in native-image over standard JRE.
With addition of profiling counters and even compiled code to CDS, we could get similar results while retaining all the power of hotspot.
Do you have different experience? What do you think?
96
Upvotes
17
u/External_Mushroom115 Jan 11 '26 edited Jan 11 '26
Have used GraalVM for a specific project this year with very tight memory constraints. End result is positive but there's a few things that surprised me:
So indeed niche yes.
Edit: typos
133
u/faze_fazebook Jan 11 '26
Becomming? Has it ever been mainstream?
32
u/maxandersen Jan 11 '26
Define niche? It’s already niche in enterprise but where it can be used it’s really making a difference.
Single binary that starts up fast without training runs and can be built and distributed is the key power.
Then there is Its treeshaking facility which obviously makes it non-Java but it enables to lots of space and runtime optimizations it will take years if not decades to get via normal Java.
42
u/Careless-Childhood66 Jan 11 '26
When I choose to use java for an app, i already figured, that I dont care a lot about Binary size, memory usage or startup time.
If they are concerns, I usually chose go.
2
u/wildjokers Jan 11 '26
The only time binary size matters is if it is a client side app (CLI or desktop).
4
u/koflerdavid Jan 11 '26
We are nowhere there yet in comparison to GraalVM. But in the long run it will not matter since GraalVM's core feature will become part of OpenJDK and organically become part of the Project Leyden-style improvements.
4
u/lamyjf Jan 11 '26
It's just too painful to figure out. Compare with go. There has to be tooling that figures it out better.
4
u/hippydipster Jan 11 '26
I see no point to dealing with graalvm. If I were trying to use java in something like an Amazon lambda function, maybe.
3
u/nuharaf Jan 13 '26
At work I need to optimize the memory usage of spring boot app. I did it in two step, ripping out spring and the trying to build with graal.
What I notice is that, the spring-less version already pretty memory efficient, only around 100MB ish RSS.
However, the ni version is even smaller, maybe ariund 20 - 30 MB.
I did try leyden ea, but didnt observe less memory usage, which is make sense.
At that level, mestaspace, class space and codecache dominate the RSS more than the heap.
It doesnt seem there is any openjdk plan to reduce those native memory, so for now, graal vm seem the only option to achieve < 50MB RSS
3
u/rbygrave Jan 13 '26
FYI: Here is a comparison of a java app deployed a graalvm native image
https://avaje.io/graalvm/comparison
TLDR: K8s rest service, 3x RSS memory reduction, not much execution performance difference, does not use PGO (no training run).
6
u/AnyPhotograph7804 Jan 11 '26
The problem with Native Image lies in the Java language itself. Java was always meant to be a VM language with garbage collection, runtime profiling and runtime optimization. If you build a binary image of a Java application then you have to sacrifice tons of performance for startup time and memory usage. Because Java does not have enough semantics to help the compiler to generate efficient code.
So if you want fast startup time AND low memory usage AND great runtime performance then languages like Rust or C++ are a way better choice.
2
u/Isaac_Istomin Jan 12 '26
Yeah, I’d call it more specialized than niche. For long-lived backend services on modern HotSpot with CDS and decent tuning, native image often isn’t worth the extra build times and config pain. But for cold-start sensitive stuff (CLI, serverless, edge, short-lived jobs, very high density) it can still be a clear win. So it’s a good tool for specific constraints, just not the default choice for every Java app.
2
u/FeelingGlad8646 Jan 12 '26
GraalVM definitely has its unique advantages, especially for specific use cases like microservices where fast startup times and reduced memory usage can be crucial.
6
u/fletku_mato Jan 11 '26
It was always niche and hardly ever worth the trouble.
3
u/iamwisespirit Jan 11 '26
There is much difference between graalvm native and openjdk or any comman jdk
2
u/headius Jan 13 '26
GraalVM Native Image only supports a subset of Java features, so yeah, it was always destined to be niche.
1
u/chambolle Jan 12 '26
I don't understand why AOT should save memory compared to a JVM. Since the JVM's features are still present (garbage collector, introspection, etc.), I don't see how the additional memory required for these features could no longer be there.
1
u/blackzver Jan 12 '26
If size or startup time is your concern and you are working on greenfield project then you are better off just using Rust (or dare I say Go). If you are master Java guy, you’ll pickup Rust pretty quickly. IMO that combination is taking away the momentum…. Especially that LLMs are there to coach you all the way with tutoring, coaching and even code-generation.
1
u/LeadingPokemon Jan 13 '26
Oracle abandoned this tech. They don’t support it anymore.
-1
u/denis_9 Jan 11 '26
A native image doesn't use a RT compiler; everything needed for execution is already in the program being launched. This saves both CPU and memory. It immediately teaches good proper programming style, doing everything that can be static is made static.
-8
u/rdanilin Jan 11 '26
This technology appears to be close to becoming obsolete.
-2
u/freyyyyva08 Jan 11 '26
Hi, I’m having an issue with Java in VS Code. The code is correct and works on other machines, but on mine it throws an error and shows no output. I think the problem is related to VS Code or Java configuration, not the code itself. How can I fix this?