Get the latest tech news
How ZGC allocates memory for the Java heap
This post explores how ZGC, one of the garbage collectors in the OpenJDK, allocates memory for the Java heap, focusing on enhancements introduced in JDK-8350441 with the Mapped Cache. A garbage collector does much more than just collect garbage - and that’s what I want to unpack in this post. Whether you’re a Java nerd yearning for details, a GC enthusiast, or just curious about how ZGC uses memory behind the scenes, this deep dive is for you.
This post explores how ZGC, one of the garbage collectors in the OpenJDK, allocates memory for the Java heap, focusing on enhancements introduced in JDK-8350441 with the Mapped Cache. If latency is a critical concern, you should disable uncommit, either explicitly by using the-XX:-ZUncommit flag, or implicitly by setting the minimum and maximum heap sizes to the same value. While this is rarely an issue, it’s worth noting that, for historical reasons, the maximum number of memory mappings on Linux is by default set to 65530, which is relatively low.
Or read this on Hacker News