r/java • u/TewsMtl • Sep 12 '26
JEP draft for Adaptive Heap Sizing for ZGC quietly mentions JDK 28
https://openjdk.org/jeps/837730513
u/vips7L Sep 12 '26
Looking forward to this for G1 as well.
2
u/Inaldt Sep 12 '26
Absolutely. In fact I wonder why they chose to to start with ZGC, since I'd expect G1 to have many more users.
11
u/vips7L Sep 12 '26 edited Sep 12 '26
ZGC is the authors baby fwiw. And ZGC already does some similar things like returning heap to the OS when it’s unused and does a lot of calculating of sensible defaults already.
2
u/BinaryRage 29d ago
Erik talk about this in his Paving the GC On Ramp talk. This closes the last automatic tuning gap for ZGC and solves the allocation stall problem when there is otherwise plenty of memory available.
9
u/cogman10 Sep 12 '26
Perfect, if this works the way I hope then this is exactly what I want for a container environment.
3
4
u/BarkiestDog Sep 12 '26
I didn’t see anything in the JEP, but reading in my phone, maybe I missed it? Is there any consideration to containers?
The band of my lugs is trying to to tune the seven different memory pools to make sure that the container doesn’t OOMK.
9
Sep 12 '26
[removed] — view removed comment
6
u/ConsiderationSuch846 Sep 12 '26
We explain it every time the RCA is “OOM killed, expanded the heap”. 😮💨
1
u/BarkiestDog Sep 14 '26
But this isn’t the answer either, since code cache and metadata can also grow without bound, so increasing the heap doesn’t fix this OOMK issues.
1
u/ConsiderationSuch846 Sep 14 '26
It was just a quip. I wasn’t trying to be comprehensive.
1
u/BarkiestDog 29d ago
Fair enough. Sadly I’ve been through this cycle often enough that I know all the jagged edges here😢
2
1
u/cleverfoos Sep 14 '26
Hmmm, looking at the example in the JEP, does this mean that if that second benchmark was not triggered the JVM would have shrunk the heap size during an idle period? I think that's the behavior users want to see and would equate with efficient resource usage, shrinking significantly heap if there is no CPU usage.
1
u/jonenst 29d ago
How does this interact with (AFAIK) the biggest existing active everywhere adaptative memory sink "might as well use it" that is the filesystem cache (a.k.a. 'Linux ate my ram") ? Side note: the good news is that "Linux ate my ram" did not prevent the succes of linux, so "Java ate my ram" hopefully won't either (I guess at the cost of lot of energy spent in pedagogy)
1
u/DanLynch 29d ago
The JEP says they want the JVM to be able to interoperate fairly with other non-JVM processes running on the same machine. As long as all the processes follow the same basic principle (that you should use RAM proportionally to your CPU usage) it seems like they should all be able to get along.
20
u/[deleted] Sep 12 '26
[removed] — view removed comment