r/java • • Oct 23 '26

OpenJDK 28 EA build 21 (https://jdk.java.net/28/) is out, with Adaptive Heap Sizing and faster startup for ZGC

Post image
131 Upvotes

19 comments sorted by

7

u/cogman10 29d ago

Awesome. This will make it SO much easier to right size containers and VMs for java applications. It also gets rid of a major issue people have with Java "It uses too much memory".

2

u/Afonso2002 Oct 23 '26

Wich tool ate you using to see heap graph?

2

u/jonenst Oct 24 '26

Congratz to the whole team!! Looking forward to seeing the benefits of this cooperating feature in the wild!

1

u/eosterlund Oct 24 '26

Thank you, and hope you enjoy it.

2

u/jonenst Oct 24 '26

Is there a writeup somewhere on how it differs / improves on the existing ZUncommitDelay (or looking in the future for g1, G1PeriodicGCInterval) ? Not just in theory, but practical consequences, use cases and deployment resources planning and utilization efficiency ? Cheers

2

u/MinimumPrior3121 Oct 23 '26

But ZGC still doesnt handle compressed OOPS compared to G1 so that's bad for workloads below 32gb of heap size

18

u/eosterlund Oct 24 '26

GC is full of trade-offs. For a concurrent moving collector to ”handle compressed OOPS” in many ways causes other inefficiencies due to the inability of using colored pointers. Because of that - we are unlikely to add compressed oops for ZGC.

For example, ZGC may immediately reclaim memory when objects of a heap region has moved, even though the pointers have not been remapped. It can distinguish 3 pointers with the same address as referring to 3 different objects. This improves memory efficiency a lot. With compressed oops, this is not possible. The difference can easily be as big as compressed oops. Such things help scalability in large heaps.

Naturally without concurrent object movement you can worry less about these things and better use compressed oops without paying for it with memory. Then the currency is instead latency trade-offs. Partially for your own JVM but also others that share CPUs.

As for smaller heaps, note that there are really 3 different compressed oops encodings with different levels of addressability vs CPU efficiency trade-offs:
0-2 GB: No encoding/decoding
2-30 GB: Shift based encoding/decoding
30-32 GB: Heap base if not null + shift encoding/decoding

The last level is particularly nasty. Anyhow, this goes a bit against our scalability goal. Since there is an addressability vs efficiency trade-off, we usually rely on knowing what the max heap size will be when the JVM starts. This makes it hard to size the heaps automatically without user input. It will involve compromises that ZGC doesn’t need.

I could be wrong but I think the bigger problem for memory efficiency in smaller deployments is rather that memory resources are statically locked up based on their max need, while significantly less is needed on average. That’s why I looked at adaptive heap sizing first - to allow memory to be more efficiently shared and move to where it’s needed. Effectively leveraging the flexible heap layout we have obtained by not eating from the compressed oops apple.

Anyway, you can try it and see if you have any problems.

1

u/Deep_Age4643 29d ago

I love your talks.

1

u/eosterlund 29d ago

Thank you. :-)

12

u/pron98 Oct 23 '26

It makes up for that in other ways. I would at least try ZGC, especially with adaptive heap sizing, on every non-batch program before deciding not to use it.

3

u/vips7L Oct 23 '26

Are you guys still going to try for adaptive heap sizing in G1? 

6

u/pron98 Oct 23 '26

I'm not up to date on that, but I believe so.

2

u/vips7L Oct 24 '26

Awesome looking forward to it. 

1

u/woj-tek 26d ago

Thank you for the confirmation/suggestion. That would make (default now!) G1GC absolutely great choice for majority of deployments! <3

1

u/TheGreatAccountName 28d ago

Then you should look into Shenandoah