After several tests found that eom is not prevented. Major reason in testing was assumption future GC will free avg of last 5 GC. Disabeling this check improved eom exceptions. Added simplest testcase used for verificationpull/1/head
parent
8ff76f8682
commit
df83fcc4fc
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
package net.yacy.kelondro.util;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
|
public class MemoryControlTest {
|
||||||
|
|
||||||
|
final int onemb = 1024 * 1024;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of request method, of class MemoryControl.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testRequest_StandardStrategy() {
|
||||||
|
MemoryControl.setStandardStrategy(true);
|
||||||
|
MemoryControl.setProperMbyte(24);
|
||||||
|
|
||||||
|
int memblock = onemb * 13; // memsize to allocate
|
||||||
|
|
||||||
|
int iterations = (int) MemoryControl.available() / memblock;
|
||||||
|
int arraysize = (int) MemoryControl.maxMemory() / memblock + 10;
|
||||||
|
|
||||||
|
byte[][] x = new byte[arraysize][];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while (i < arraysize && MemoryControl.request(memblock, false)) {
|
||||||
|
x[i] = new byte[memblock];
|
||||||
|
// for realistic test produce some memory avail to GC
|
||||||
|
if (MemoryControl.request(memblock, false)) {
|
||||||
|
x[i] = new byte[memblock];
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
System.out.println("allocated " + i + " * " + memblock/onemb + " MB = " + i*memblock/onemb + " MB");
|
||||||
|
|
||||||
|
assertTrue(i >= iterations);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue