Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8368959

G1: IHOP calculation selects very low threshold and stays there

XMLWordPrintable

    • gc

      When running this program with -Xms100M -Xmx100M, beginning with JDK 23 (b08?) G1 starts behaving very badly as automatic IHOP kicks in: it reduces the heap size to zero, effectively using 5M of heap from then on.

      This results in ~900 garbage collections, which are always concurrent start ones.

      public class MixedGcHumongous {
          public static void main(String[] args) throws Exception {
              System.gc(); // start from stable state
              for (int i = 0; i < 1000; i++) {
                  Integer[] humongous = new Integer[200_000]; Thread.sleep(10); // ~0.8MB (humongous)
                  allocateTempNormal(20_000); Thread.sleep(10); // 40 bytes per entry = ~2MB
              }
          }
          static void allocateTempNormal(int count) throws Exception {
              java.util.LinkedList<Integer> temp = new java.util.LinkedList<>();
              for (int j = 0; j < count; j++) temp.add(j);
          }
      }

      The difference seems to be that in earlier JDK versions, G1 never reaches the point where adaptive IHOP kicks in, so heap is limited to the default IHOP (45%).

      This is also kind of "fixed" (more worked around) with JDK-8048180 eager reclaim of humongous objects with references, but obviously that is incidental.

            tschatzl Thomas Schatzl
            tschatzl Thomas Schatzl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: