[ https://issues.apache.org/jira/browse/HARMONY-4114?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505077
]
Vera Petrashkova commented on HARMONY-4114:
-------------------------------------------
I think the fix of this bug is not complete.
If we change fragTest to define MAX_MEM value as test argument (see new test) then it passes
with MAX_MEM 44000000 but it fails
when MAX_MEM=58000000.
On RI this test
-------------fragTest.java----------
public class fragTest {
public final static int NUM_IT = 1000000;
public static int MAX_MEM = 44000000; // change this field description
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 { // add MAX_MEM
definition
if (args.length > 0) {
MAX_MEM = Integer.parseInt(args[0]);
}
} catch (Throwable e) {
}
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");
}
}
}
-------------------------
java -Xmx64M fragTest 44000000
java -Xmx64M fragTest 58000000
On RI:
=====
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
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 = 58000000
On Harmony-r547521
=============
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
icensors, as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r547521, (Jun 15 2007), Windows/ia32/msvc 1310, release build
http://harmony.apache.org
The GC did not provide gc_add_weak_root_set_entry()
Test passed, Total size = 44000000
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
icensors, as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r547521, (Jun 15 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 = 56556930 i = 10635
Test failed
> [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
> Assignee: Xiao-Feng Li
> Priority: Minor
> Attachments: patch-for-H4114-001.patch
>
>
> 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.
|