Hacker News Viewer

The G1 Garbage Collector

by ejboy on 11/17/2026, 4:29:07 AM

https://dev.java/learn/jvm/tool/garbage-collection/g1gc-overview/

Comments

by: brunoborges

Lots of details that teams miss when tuning the JVM on Kubernetes:<p>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;<p>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.<p>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&#x2F;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).<p>I&#x27;ve been advocating on this for years [1].<p>[1] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=wApqCjHWF8Q" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=wApqCjHWF8Q</a>

11/20/2026, 6:55:52 PM


by: 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.

11/20/2026, 4:01:32 PM


by: ahmedfromtunis

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

11/20/2026, 4:37:42 PM


by: 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.

11/17/2026, 5:18:13 AM


by: cyberax

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

11/20/2026, 6:07:16 PM


by:

11/17/2026, 4:42:44 AM


by: pancakeguy

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

11/20/2026, 6:50:47 PM


by: _verandaguy

Tangential, but I really dislike that the `.java` gTLD was allowed to come about given it&#x27;s also a reasonably popular file extension.<p>The `.zip` gTLD set a really bad precedent.

11/20/2026, 3:08:07 PM