harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vera Petrashkova (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4114) [drlvm][gc] GC cannot work with fragmented heap with small heap size
Date Sat, 09 Jun 2007 08:44:26 GMT
[drlvm][gc] GC cannot work with fragmented heap with small heap size
--------------------------------------------------------------------

                 Key: HARMONY-4114
                 URL: https://issues.apache.org/jira/browse/HARMONY-4114
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
         Environment: Windows
            Reporter: Vera Petrashkova
            Priority: Minor


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)


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message