jmap histo:live different behavior with ZGC

David Tavoularis David.Tavoularis at mycom-osi.com
Tue Jul 6 15:46:24 UTC 2021


Hi Erik,

> So other than a GC not showing up in the log, is there any actual  
> observable difference in behaviour?
None. Your explanation makes perfectly sense.
What I am trying to achieve in labs is to measure the max retained memory  
by doing regular "jmap -histo:live" during my workload.
I wanted to make sure that garbage-collectable objects were not counted by  
this command when using ZGC.

Best Regards
David

On Mon, 05 Jul 2021 20:09:26 +0200, Erik Osterlund  
<erik.osterlund at oracle.com> wrote:

> 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