Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-4114

[drlvm][test] Fragmentation related tests report failure for lower heap utilization rate than RI

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • None
    • None
    • DRLVM
    • None
    • Windows

    Description

      VM intermittently throws unexpected OutOfMemoryError on the following test which defines heap fragmentation.

      This test allocates bytes arrays of different sizes.
      The arrays sizes are up to the defined MAX memory, but it is always checked that the total arrays size does not reach this MAX value.
      Some of the arrays are deleted (assigned to null) with the step which varies from 2 to 13, so, fragmentation of heap becomes high.

      Test fails on DRLVM with -Xmx64M and sometimes VM crashes on this test without of throwing OutOfMemoryError.

      On RI this test always passes with -Xmx64Mю
      ------------fragTest.java-----------
      public class fragTest {
      public final static int NUM_IT = 1000000;
      public final static int MAX_MEM = 44000000;
      public final static int BSIZE = 65536;
      public final static int MIN_BSIZE = 1;
      public final static int PERIOD = 25000;
      static int count=0;
      static int totalSize = 0;

      public static byte [][] ref = new byte [NUM_IT][];
      public static void main(String[] args) {
      int i = 0;
      try {
      for (; i < NUM_IT; ++i) {

      // size varies from MIN_BSIZE to (BSIZE + MIN_BSIZE)
      int size = ((i + BSIZE) % BSIZE) + MIN_BSIZE;
      while (totalSize + size > MAX_MEM)

      { size = size / 2; if (size < MIN_BSIZE) break; }

      if (size >= MIN_BSIZE)

      { ref[i] = new byte[size]; totalSize += size; }

      count++;
      // clearing of arrays on PERIOD step
      if (count > PERIOD) {
      // clearing of arrays is perfromed with the step,
      // which varies from 2 to 13, so, the heap becomes
      // fragmented
      int step = (i % 13) + 2;

      for(int j = 0; j<i; j+=step) {
      if ( ref[j]!= null)

      { totalSize-=ref[j].length; //recalculate total size ref[j]= null;//clear array }

      }
      count = 0;
      // System.err.println("Total size = " + totalSize);

      }
      }
      System.err.println("Test passed, Total size = " + totalSize);
      } catch (OutOfMemoryError e)

      { System.err.println("OutOfMemoryError is thrown. Total size = " + totalSize + " i = " + i); System.err.println("Test failed"); }

      }
      }
      -----------------
      Run this test several times.
      java -Xmx64M fragTest

      On RI output always is the following:
      ===============
      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)

      Test passed, Total size = 44000000

      DRLVM output:
      =============
      Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
      java version "1.5.0"
      pre-alpha : not complete or compatible
      svn = r545076, (Jun 7 2007), Windows/ia32/msvc 1310, release build
      http://harmony.apache.org
      The GC did not provide gc_add_weak_root_set_entry()
      OutOfMemoryError is thrown. Total size = 39269205 i = 50083
      Test failed

      Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
      java version "1.5.0"
      pre-alpha : not complete or compatible
      svn = r545076, (Jun 7 2007), Windows/ia32/msvc 1310, release build
      http://harmony.apache.org
      The GC did not provide gc_add_weak_root_set_entry()
      Out of Memory!

      This bug causes the itermittent failures of gc.frag tests from stress test suite (http://issues.apache.org/jira/browse/HARMONY-3536)

      Attachments

        1. stress_1.patch
          1.16 MB
          Alexei Fedotov
        2. stress_1.patch
          1.12 MB
          Alexei Fedotov
        3. stress_1.patch
          1.12 MB
          Alexei Fedotov
        4. stress_1.patch
          1.12 MB
          Alexei Fedotov
        5. harness_test_handler.patch
          30 kB
          Alexei Fedotov
        6. add_remove.sh
          8 kB
          Alexei Fedotov
        7. add_remove.sh
          8 kB
          Alexei Fedotov
        8. stress.patch
          1.12 MB
          Alexei Fedotov
        9. check_xml_id.sh
          0.2 kB
          Alexei Fedotov
        10. check_source_tag.pl
          3 kB
          Alexei Fedotov
        11. patch-for-H4114-001.patch
          30 kB
          Qi Ji

        Issue Links

          Activity

            People

              Unassigned Unassigned
              vpetrash Vera Petrashkova
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: