jmap histo:live different behavior with ZGC

Erik Osterlund erik.osterlund at oracle.com
Mon Jul 5 18:09:26 UTC 2021


Hi David,

The ZGC heap walker used to collect the stats, uses transitive traversal from roots, as opposed to heap parsing like the STW collectors. Doing a STW full GC and then parsing the heap, yields the same set of objects that heap walking by traversal does (ish). I suppose there is a slight difference that the traversal follows through non-strong references, while a full GC might clear them before parsing. Arguably the traversal strategy is more accurate as weakly reachable objects are still ”live” at the point the traversal happens.

So other than a GC not showing up in the log, is there any actual observable difference in behaviour?

Thanks,
/Erik

> On 5 Jul 2021, at 14:25, David Tavoularis <David.Tavoularis at mycom-osi.com> wrote:
> 
> Hi,
> 
> When using "jmap -histo:live <PID>", the JVM triggers a Garbage Collection when G1 (default GC in Java16), but not when using ZGC. Is it an expected behavior or a bug ?
> Please note that "jcmd <PID> GC.run" correctly triggers a Garbage Collection when using ZGC.
> Is there a way to measure only live objects with ZGC ?
> 
> Additional information from jmap usage about -histo[:live] : Prints a histogram of the heap. For each Java class, number of objects, memory size in bytes, and fully qualified class names are printed. VM internal class names are printed with '*' prefix. If the live suboption is specified, only live objects are counted.
> 
> Best Regards
> -- 
> David


More information about the zgc-dev mailing list