“This is the 7th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

I. Overview of ZGC

1.1 ZGC research data

Let’s take this one out in detail.

  1. ZGC website: wiki.openjdk.java.net/display/zgc…
  2. ZGC documentation (PDF, detailed explanation) : cr.openjdk.java.net/~pliden/sli…

These two articles introduce ZGC in detail. The second is a PDF file that you can download to look at in detail.

1.2 Platforms supported by ZGC

This can be in the official documentation (wiki.openjdk.java.net/display/zgc…). Jdk11 currently supports Only Linux.

JDK11 only supports Linux64 bits. In jdk4, Windows and macOS will be supported.

1.3 Objectives of the ZGC

Let’s take a look at what the goals of the ZGC are, and the goals are what the ZGC exists for.

  1. Support for larger heap memory space. How big is bigger? It used to be GB, now it’s TB. Up to 4TB of memory is supported in jdK11. (This is not the hard disk, it is the memory, emphasis on memory.) Scenarios for the next decade or two are covered.

  2. Support for shorter GC pause times, with a target of less than 10ms: this shorter GC pause time is the STW time. This is even more impressive, the memory support is hit, but the STW pause time is short.

  3. Lay the foundation for future GC functionality. Lays a foundation for future garbage collectors. If GC is to be upgraded in the future, it will be studied against the underlying ZGC algorithm. Our garbage collection has always been based on CMS, and G1, for example, is based on CMS. ZGC also builds on CMS.

  4. Throughput reduction of no more than 15% : The shorter the STW time control, the lower throughput will be. The goal of the ZGC here is to control throughput reduction by no more than 15%.

    Usually our GC time is 1000ms, but in order to reduce the STW time during GC collection, we control the STW time within 10ms, which may result in the overall GC time side being longer. It used to be 1000ms, now it’s 1150ms. This reduces throughput.

1.4 ZGC Startup command

  1. Start the ZGC and print logs: -xx :+ usezgc-xmx-xlog: GC
  2. Start ZGC and print detailed logs: -xx :+ usezgc-xmx-xlog: GC

1.5 ZGC features:

ZGC does not divide generations.

What was the reason for our previous generational divide? Because most of the subjects have the characteristics of life and death. So a dying object might want to be removed as soon as possible. As a result, gc is likely to be triggered more frequently because there are so many dead objects in it. Then each time gc, all objects are iterated over

Why did the ZGC partially bring it? Because the generation implementation is more difficult, the author first implemented a relatively simple and usable single-generation version, the subsequent optimization may be generational.

Second, ZGC memory model