Trying to understand ZGC

Stefan Reich stefan.reich.maker.of.eye at
Wed Nov 28 19:09:57 UTC 2018

Hi Per!

On Tue, 13 Nov 2018 at 20:22, Per Liden <per.liden at> wrote:

> The RSS accounting on Linux isn't always telling the complete truth and
> it can even vary depending on if you're using small or large pages. ZGC
> does heap multi-mapping, which means it will map the same heap memory in
> three different locations in the virtual address space. When using small
> pages, Linux isn't clever enough to detect that it's the same memory
> being mapped multiple times, and so it accounts for each mapping as if
> it was new/different, inflating the RSS by 3x. This typically doesn't
> happen when using large pages (-XX:+UseLargePages).

Thanks. I would call this an actual bug in Linux then. Counting memory
twice is really not OK.

Hm... are large pages really problematic as suggested here?

> >
> > When turning on GC notifications, I see (sometimes):
> >
> >    GC cause:  Allocation Rate (360 ms)
> >    Collector: ZGC
> >    Changes:   ZHeap: -16383 K, CodeHeap 'profiled nmethods': 85 K,
> Metaspace: 1 K
> >
> > and more often:
> >
> >   GC cause:  Proactive (147 ms)
> >    Collector: ZGC
> >    Changes:   ZHeap: -180223 K, CodeHeap 'profiled nmethods': 1 K,
> CodeHeap 'non-profiled nmethods': 1 K, Metaspace: 1 K, CodeHeap
> 'non-nmethods': 12 K
> >
> > Does this mean stop-the-world GC pauses are occurring, or is my
> application not paused?
> This is all normal. Each ZGC cycle has three short pauses (each of them
> should be below 10ms). If you enable detailed GC logging with
> -Xlog:gc*:gc.log you'll see more details on exactly how long the pauses
> are, and a bunch of other data points.

I still don't understand... are the GC pauses of 360/147 ms stop-the-world
pauses or just the duration of a concurrent GC cycle? (I'm just printing
all  GarbageCollectionNotificationInfo objects I get from the pertinent MX

> For more information on ZGC, how to tune, how to interpret logs,
> internals, etc., I'd recommend having a look at some of the slides
> and/or videos available here:


For now I think I'll stick to G1 as it has tolerable pauses (<50ms,
roughly, unless I call System.gc()). I do have to call System.gc()
sometimes in order to return memory to the OS.

I'm focusing on desktop use where my goal is <1GB total process size. I
assume for ZGC I would need to reserve more slack than with G1 in order to
get its full advantages?

Many greetings,

More information about the zgc-dev mailing list