Any idea why max = -1(-1K) in G1GC

Stefan Johansson stefan.johansson at oracle.com
Wed Jun 28 08:56:55 UTC 2017


Hi Sundar,

I understand that this might be a bit confusing. The -1 means undefined 
and the reason the max is undefined for Eden and Survivor is that they 
are logical spaces within the G1 heap. Technically the same is true for 
the Old Gen, but to not lose information the heap capacity is used as 
the max for Old Gen.

Some more detailed information from comments in the code:

g1MemoryPool.hpp
  35 // This file contains the three classes that represent the memory0
  36 // pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and
  37 // G1OldGenPool. In G1, unlike our other GCs, we do not have a
  38 // physical space for each of those spaces. Instead, we allocate
  39 // regions for all three spaces out of a single pool of regions (that
  40 // pool basically covers the entire heap). As a result, the eden,
  41 // survivor, and old gen are considered logical spaces in G1, as each
  42 // is a set of non-contiguous regions. This is also reflected in the
  43 // way we map them to memory pools here. The easiest way to have done
  44 // this would have been to map the entire G1 heap to a single memory
  45 // pool. However, it's helpful to show how large the eden and survivor
  46 // get, as this does affect the performance and behavior of G1. Which
  47 // is why we introduce the three memory pools implemented here.
  48 //
  49 // See comments in g1MonitoringSupport.hpp for additional details
  50 // on this model.

g1MonitoringSupport.hpp
  94 // * Max Capacity
  95 //
  96 //    For jstat, we set the max capacity of all spaces to 
heap_capacity,
  97 //    given that we don't always have a reasonable upper bound on 
how big
  98 //    each space can grow. For the memory pools, we make the max
  99 //    capacity undefined with the exception of the old memory pool for
100 //    which we make the max capacity same as the max heap capacity.

Cheers,
Stefan

On 2017-06-27 21:44, Sundara Mohan M wrote:
> When i try to get pool.getUsage() and print it i am getting
>
> G1 Eden Space
> init = 27262976(26624K) used = 0(0K) committed = 0(0K) max = -1(-1K)
> G1 Survivor Space
> init = 0(0K) used = 0(0K) committed = 0(0K) max = -1(-1K)
> G1 Old Gen
> init = 241172480(235520K) used = 0(0K) committed = 0(0K) max =
> 524288000(512000K)
>
> With ConcMarkSweepGC
>
> Par Eden Space
> init = 71630848(69952K) used = 0(0K) committed = 0(0K) max = 139853824(136576K)
> Par Survivor Space
> init = 8912896(8704K) used = 0(0K) committed = 0(0K) max = 17432576(17024K)
> CMS Old Gen
> init = 178978816(174784K) used = 0(0K) committed = 0(0K) max =
> 349569024(341376K)
>
>
> code
> for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
>     System.out.println(pool.getUsage())
> }
>
> Thanks,
> Sundar




More information about the hotspot-gc-dev mailing list