GCs with survivor spaces report Init > Max through MXBeans

XMLWordPrintable

    • gc

      Run this:

      $ cat Test.java
      import java.lang.management.ManagementFactory;

      public class Test {
        public static void main(String... args) {
           var bean = ManagementFactory.getMemoryMXBean();
           System.out.println("MXBean says: " + bean.getHeapMemoryUsage());
        }
      }

      $ java -XX:+UseParallelGC -Xms76m -Xmx76m Test.java
      MXBean says: init = 79691776(77824K) used = 9006952(8795K) committed = 76546048(74752K) max = 76546048(74752K)

      Note how init > max. This is because generational collectors report "max" as max_capacity(), which excludes one of the survivors, while reporting "init" as the vanilla Xms. The fix on the GC side, in the way they report their initial capacity.

            Assignee:
            Aleksey Shipilev
            Reporter:
            Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: