Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Won't Fix
-
None
-
None
-
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)
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)
}
count = 0;
// System.err.println("Total size = " + totalSize);
}
}
System.err.println("Test passed, Total size = " + totalSize);
} catch (OutOfMemoryError e)
}
}
-----------------
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
Attachments
Issue Links
- blocks
-
HARMONY-4108 [M2] umbrella task for 98% pass rate of Stress tests - HARMONY-3536; no regression since M1
- Closed
- incorporates
-
HARMONY-4076 [drlvm][gc] VM cashes instead of throwing OutOfMemoryError
- Closed
- is related to
-
HARMONY-4882 [drlvm][vmcore] vm throws an assertion when array size is big
- Closed
-
HARMONY-4992 [bti][stress] comparative tests on memory fragmentation
- Closed