diff options
| author | reger <reger18@arcor.de> | 2015-02-11 01:42:01 +0100 |
|---|---|---|
| committer | reger <reger18@arcor.de> | 2015-02-11 01:42:01 +0100 |
| commit | df83fcc4fc5026ce75edd680642f3d46ab5d3507 (patch) | |
| tree | 50caa95efcd5b65a68d65cc5da2ffdb5fbb9ec2b /test/net | |
| parent | 8ff76f8682c1b8a6e86438d788e7ce468a723834 (diff) | |
disable optimistic GC assumption in StandardMemoryStrategy
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 verification
Diffstat (limited to 'test/net')
| -rw-r--r-- | test/net/yacy/kelondro/util/MemoryControlTest.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/net/yacy/kelondro/util/MemoryControlTest.java b/test/net/yacy/kelondro/util/MemoryControlTest.java new file mode 100644 index 000000000..5c8666436 --- /dev/null +++ b/test/net/yacy/kelondro/util/MemoryControlTest.java @@ -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);
+ }
+
+}
|
