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

JDK8 OOM with option '-XX:MaxNewSize=1023M -XX:-UseCompress -Xms512m -Xmx1024m'

XMLWordPrintable

    • gc
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      java version "1.8.0_371"
      Java(TM) SE Runtime Environment (build 1.8.0_371-b11)
      Java HotSpot(TM) 64-Bit Server VM (build 25.371-b11, mixed mode)

      OS: windows 11

      A DESCRIPTION OF THE PROBLEM :
      Despite setting a small heap memory size in the JVM options, only the ParallelGC in JDK8 experienced an OutOfMemory error. Other GCs such as Serial/G1/CMS did not encounter OOM, and neither did JDK11 and JDK17. Furthermore, my program should only occupy approximately 200MB of memory space, which should not result in an OutOfMemory error.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Step1. Create Case.java or download the Case.class from the following link.
      https://drive.google.com/file/d/1oiS8fV0L181CrUz8jjh1qnGwYH7wtY90/view?usp=share_link

      public class Case {
          public String str;
          public float[][][] floatArray = new float[32][32][256];
          protected long[][][] longArray = new long[64][256][256];
          private Object[][][] objArray = new Object[256][64][256];

          public Case() {
          }

          public static void main(String[] var0) {
              Case instance = new Case();
              new Case();
              instance.str = new String();
              new Case();
          }

      Step2. run the cmd 'java -XX:MaxNewSize=1023M -Xms512m -Xmx1024m -XX:-UseCompressedOops -XX:+UseParallelGC Case' (with JDK8u371)

      >java -XX:MaxNewSize=1023M -Xms512m -Xmx1024m -XX:-UseCompressedOops -XX:+UseParallelGC Case
      Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
              at Case.<init>(Case.java:10)
              at Case.main(Case.java:15)

      >java -XX:MaxNewSize=1023M -Xms512m -Xmx1024m -XX:-UseCompressedOops -XX:+UseSerialGC Case
      <no output>

       >java -XX:MaxNewSize=1023M -Xms512m -Xmx1024m -XX:-UseCompressedOops -XX:+UseG1GC Case
      <no output>

      >java -XX:MaxNewSize=1023M -Xms512m -Xmx1024m -XX:-UseCompressedOops -XX:+UseConcMarkSweepGC Case
      <not output>


      ACTUAL -
      java -XX:MaxNewSize=1023M -Xms512m -Xmx1024m -XX:-UseCompressedOops -XX:+UseParallelGC -XX:+PrintGCDetails Case

      [GC (Allocation Failure) --[PSYoungGen: 131584K->131584K(153088K)] 131584K->132608K(154112K), 0.0118525 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [Full GC (Ergonomics) [PSYoungGen: 131584K->127828K(153088K)] [ParOldGen: 1024K->781K(1024K)] 132608K->128610K(154112K), [Metaspace: 2640K->2640K(8192K)], 0.0163793 secs] [Times: user=0.03 sys=0.00, real=0.02 secs]
      [GC (Allocation Failure) --[PSYoungGen: 131584K->131584K(153088K)] 132365K->132605K(154112K), 0.0090990 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [Full GC (Ergonomics) [PSYoungGen: 131584K->131399K(153088K)] [ParOldGen: 1021K->964K(1024K)] 132605K->132363K(154112K), [Metaspace: 2640K->2640K(8192K)], 0.0317191 secs] [Times: user=0.00 sys=0.00, real=0.03 secs]
      [GC (Allocation Failure) --[PSYoungGen: 131584K->131584K(153088K)] 132548K->132604K(154112K), 0.0094816 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
      [Full GC (Ergonomics) [PSYoungGen: 131584K->131540K(153088K)] [ParOldGen: 1020K->1006K(1024K)] 132604K->132546K(154112K), [Metaspace: 2640K->2640K(8192K)], 0.0118827 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [GC (Allocation Failure) --[PSYoungGen: 131584K->131584K(153088K)] 132590K->132606K(154112K), 0.0092376 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [Full GC (Ergonomics) [PSYoungGen: 131584K->131570K(153088K)] [ParOldGen: 1022K->1018K(1024K)] 132606K->132589K(154112K), [Metaspace: 2640K->2640K(8192K)], 0.0093009 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [GC (Allocation Failure) --[PSYoungGen: 131584K->131584K(153088K)] 132602K->132602K(154112K), 0.0088262 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [Full GC (Ergonomics) [PSYoungGen: 131584K->131582K(153088K)] [ParOldGen: 1018K->1018K(1024K)] 132602K->132601K(154112K), [Metaspace: 2640K->2640K(8192K)], 0.0091113 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
      [GC (Allocation Failure) --[PSYoungGen: 131582K->131582K(153088K)] 132605K->132605K(154112K), 0.0093343 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [Full GC (Ergonomics) [PSYoungGen: 131582K->131582K(153088K)] [ParOldGen: 1022K->1022K(1024K)] 132605K->132605K(154112K), [Metaspace: 2640K->2640K(8192K)], 0.0114478 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [GC (Allocation Failure) --[PSYoungGen: 131582K->131582K(153088K)] 132605K->132605K(154112K), 0.0096056 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
      [Full GC (Allocation Failure) [PSYoungGen: 131582K->131564K(153088K)] [ParOldGen: 1022K->1022K(1024K)] 132605K->132587K(154112K), [Metaspace: 2640K->2640K(8192K)], 0.0104933 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [GC (Allocation Failure) --[PSYoungGen: 131584K->131584K(153088K)] 132606K->132606K(154112K), 0.0091513 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [Full GC (Ergonomics) [PSYoungGen: 131584K->131582K(153088K)] [ParOldGen: 1022K->1022K(1024K)] 132606K->132605K(154112K), [Metaspace: 2640K->2640K(8192K)], 0.0180508 secs] [Times: user=0.01 sys=0.00, real=0.02 secs]
      [GC (Allocation Failure) --[PSYoungGen: 131582K->131582K(153088K)] 132605K->132605K(154112K), 0.0093444 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      [Full GC (Allocation Failure) [PSYoungGen: 131582K->131582K(153088K)] [ParOldGen: 1022K->1022K(1024K)] 132605K->132605K(154112K), [Metaspace: 2640K->2640K(8192K)], 0.0111595 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
      Exception in thread "main" [GC (Allocation Failure) --[PSYoungGen: 131584K->131584K(153088K)] 132607K->132607K(154112K), 0.0041269 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
      [Full GC (Ergonomics) [PSYoungGen: 131584K->0K(153088K)] [ParOldGen: 1023K->770K(1024K)] 132607K->770K(154112K), [Metaspace: 2664K->2664K(8192K)], 0.0027879 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
      java.lang.OutOfMemoryError: Java heap space
              at Case.<init>(Case.java:10)
              at Case.main(Case.java:15)
      Heap
       PSYoungGen total 153088K, used 2832K [0x00000239a8300000, 0x00000239b2d80000, 0x00000239e8200000)
        eden space 131584K, 2% used [0x00000239a8300000,0x00000239a85c4068,0x00000239b0380000)
        from space 21504K, 0% used [0x00000239b1880000,0x00000239b1880000,0x00000239b2d80000)
        to space 21504K, 0% used [0x00000239b0380000,0x00000239b0380000,0x00000239b1880000)
       ParOldGen total 1024K, used 770K [0x00000239a8200000, 0x00000239a8300000, 0x00000239a8300000)
        object space 1024K, 75% used [0x00000239a8200000,0x00000239a82c0b20,0x00000239a8300000)
       Metaspace used 2673K, capacity 4100K, committed 4352K, reserved 8192K


      ---------- BEGIN SOURCE ----------
      public class Case {

          public String str;
          public float[][][] floatArray = new float[32][32][256];
          protected long[][][] longArray = new long[64][256][256];
          private Object[][][] objArray = new Object[256][64][256];


          public static void main(String[] var0) {
              Case instance = new Case();
              new Case();
              instance.str = new String();
              new Case();
          }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: