RFC: Adaptively resize heap at any GC/SoftMaxHeapSize for G1

Thomas Schatzl thomas.schatzl at oracle.com
Fri Jul 17 09:55:55 UTC 2020


On 07.07.20 18:23, Ruslan Synytsky wrote:
>>>> Unfortunately GC.heap_info and VM.info do not provide information about
>>>> COMMITTED heap. And jstat documentation
>> That is actually not true :) While looking into JDK-8248136, G1 actually
>> already prints committed heap with GC.heap_info.
>> E.g. on an application with -Xms64m -Xmx1024m the output is:
>> $ jcmd 30653 GC.heap_info
>> 30653:
>>    garbage-first heap   total 519168K, used 315920K [0x00000000c0000000,
>> 0x0000000100000000)
>>     region size 1024K, 116 young (118784K), 23 survivors (23552K)
>> [...]
>> The "total" is "available" regions (i.e. ~committed) as explained in the
>> previous post (I kept the relevant part below).
> Thomas, thank you, it helps! I'm glad that I was wrong. The "total" naming
> confused me, I was thinking it's the max (Xmx) heap.
> As a follow up question - how to get the non heap usage? It can be useful
> for understanding of the full picture. JMX provides the following option:

The only thing I can think of at this time is using NMT output (which is 
probably much more accurate than what the MX-Beans provide), but this 
needs you to enable it at startup.

> *MemoryMXBean mem = ManagementFactory.getPlatformMXBean(mbsc,
> MemoryMXBean.class);MemoryUsage nonHeap =
> mem.getNonHeapMemoryUsage();System.out.println(nonHeap.getInit() + "," +
> nonHeap.getUsed() + "|, + nonHeap.getCommitted() + "," + nonHeap.getMax());*
>> I recently filed JDK-8248136 for improving the heap info output for G1.
> Improving the heap info sounds like a useful enhancement. At the moment
> GC.heap_info is printed by different GCs with different naming.


> Shenandoah provides the most distinct output including Xmx which is called
> "total" while "total" means committed in G1. Also ZGC prints committed heap
> as capacity while metaspace has both capacity and committed... Does it make
> sense to harmonize the naming?

:) I noticed that as well when looking for that info. I will file an 
enhancement to see whether the output can be streamlined slightly. 
Thanks for the reminder.


More information about the hotspot-gc-dev mailing list