The G1 Garbage Collector

ejboy 118 points 77 comments November 17, 2026
dev.java · View on Hacker News

Discussion Highlights (7 comments)

Sid_Lmao

Easy-to-miss detail: before JDK 27, the JVM only picked G1 with 2+ CPUs and ~1.8 GB of memory; otherwise, it silently used SerialGC. So a lot of 1- CPU Kubernetes pods have been on serial all along. Worth checking with -XX:+PrintCommandLineFlags before upgrading, since GC behaviour will change.

_verandaguy

Tangential, but I really dislike that the `.java` gTLD was allowed to come about given it's also a reasonably popular file extension. The `.zip` gTLD set a really bad precedent.

Fizzadar

I remember switching on G1GC for Elasticsearch back in 2014 and it was a total game changer for cluster stability (ES had plenty of other warts back then to counter the improvement). Cool to see it land as the default everywhere over a decade later.

ahmedfromtunis

I love that they also have learn.java and inside.java. They should make get.java point to the download page. Oh and docs.java would be very cool!

cyberax

And still no automatic heap sizing... Maybe next year?

pancakeguy

garbage collection will almost certainly be a relic of the past surprisingly soon. Fundamentally it exchanges efficiency for readability & developer experience, to things that do not matter when using AI to write code.

brunoborges

Lots of details that teams miss when tuning the JVM on Kubernetes: 1. Default heap size varies: it can be 50% of the available memory for any amount of available memory up to 256mb; ~128mb for anywhere between 256 and 512; and then 25% for anything above 512mb; 2. The JVM will still do parallel threads even when CPU limit is 1,000 or below , which triggers CPU throttling much faster. Threads such as GC (even when it is SerialGC), ForkJoin pools, Database connection pools, HTTP server, and so on. 3. The JVM behaves MUCH better with 2,000 or more milicores, and a well sized heap. Having very small containers and dozens of replicas is worse than having slightly bigger containers (cpu/memory limits) and fewer replicas, even with a different ratio (e.g. 6 replicas will perform worse than 3 replicas, even when aggregated CPU and memory limits are the same). I've been advocating on this for years [1]. [1] https://www.youtube.com/watch?v=wApqCjHWF8Q

Semantic search powered by Rivestack pgvector
3,874 stories · 35,194 chunks indexed