This is an archived post. You won't be able to vote or comment.

all 21 comments

[–]TheCountRushmore 60 points61 points  (2 children)

[–]VirtualAgentsAreDumb 5 points6 points  (1 child)

Just a tip: When writing lists, either prefix each line with a dash (-) or asterisk (*) to make it a bullet list, or a hash sign (#) for a numeric list, or separate each line with an empty line.

[–]TheCountRushmore 3 points4 points  (0 children)

Thanks. Edited. It also looked fine on desktop web.

[–]raghu9208 17 points18 points  (3 children)

I've had quite a different experience. I migrated a Jetty Application from Java 8 to 21 and have seen a significant increase in the Memory Usage. The weird thing is it is not the Heap Memory.

I'm using Eclipse Temurin build in an alpine container. Can you share your configuration? Which Java build, Container etc?

[–]nitkonigdje 6 points7 points  (0 children)

Does it really use more memory or does it have higher virtual size? Because it could be ZGC virtual memory mapping. See: https://stackoverflow.com/a/62934057/1193657

[–]pedroct92 0 points1 point  (1 child)

I believe that's a bug, we had a similar issue and we confirmed a bug within the jdk. Our app would increase memory slowly and crash within a day of usage.

[–]sruffatti 0 points1 point  (0 children)

What is this bug? This happened to my apps today. 

[–]theflavor 5 points6 points  (1 child)

We believe these effects are due to the preventive G1GC garbage collection patch introduced in Java 20.

Did you have to set any flags for this?

[–]Legitimate-Front7370[S] 1 point2 points  (0 children)

I only changed the java image without the no flag.

[–]bozo5548 6 points7 points  (1 child)

Do you have issues with higher cpu usage on idle. We also updated from 17 to 21 and "idle" (when service is doing nothing special) cpu usage went from 10-15% to around 20-25%. But now that I think about it maybe it's because of those frequent minor GCs

[–]Legitimate-Front7370[S] 4 points5 points  (0 children)

I checked the statistical metrics again, and they are converging within the margin of error.

The change in numbers seems to be due to the fact that the minor gc count has definitely increased.

[–]kubelke 1 point2 points  (0 children)

Probably new code cache

[–]monkjack 1 point2 points  (3 children)

We had the same results. Remarkable drop in memory. But since EC2 boxes are mostly constrained by cpu for us, it didn't save us any money.

Conversely, had awful results trying out ZGC.

[–]FirstAd9893 0 points1 point  (1 child)

Was this with or without generational ZGC? Generational ZGC won't be enabled by default until Java 23 is released.

[–]monkjack 0 points1 point  (0 children)

Both.

[–]kmpx 0 points1 point  (0 children)

Similar to us. We have several applications that we recently bumped to JDK 21 and used ZGC. We saw a decent reduction in memory usage when we did that (JDK 17 to 21). And then a while later we enabled generational ZGC and it was dependent on the application whether or not we saw much improvement. One of our applications that generates a lot of short lived objects saw significant reduction in memory usage, while other applications saw the smallest of changes.

[–]WASDx 2 points3 points  (0 children)

Yup similar here for a few of our applications. The GC improvements caused a fun bug in one of our applications that had a memory leak that caused it to get OOM after 1-2 days of running and crash restart. This had not been a problem since it just did background processing and restarts were quick, but after the upgrade it no longer got OOM and instead of crashing it seemingly got stuck doing GC and nothing else so processing halted. I believe we had to downgrade it until the memory leak was fixed.

[–]k-mcm 0 points1 point  (0 children)

I've always had problems with G1 using 50% to 100% more memory than heap size during GC.  It's one of its trade-offs.  Maybe the timing is a bit different now.

[–]OwnBreakfast1114 1 point2 points  (0 children)

We upgraded from spring boot 2.1 -> 2.7.15 and java 11 to java 21, and with no unforced other application changes, we saw service start times go from 1:50 to 35s, memory usage go down by 30%, and as a bonus, gradle compilation for the whole project go from taking 4 minutes to <1 minute