Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fix for (false) oom
orbiter6083f2f1716d
diff --git a/source/net/yacy/kelondro/blob/HeapReader.java b/source/net/yacy/kelondro/blob/HeapReader.javaindex 22f8449a0..7dbe44dc8 100644--- a/source/net/yacy/kelondro/blob/HeapReader.java+++ b/source/net/yacy/kelondro/blob/HeapReader.java@@ -51,7 +51,7 @@ import net.yacy.kelondro.util.MemoryControl;public class HeapReader {- public final static long keepFreeMem = 20 * 1024 * 1024;+ //public final static long keepFreeMem = 20 * 1024 * 1024;// input valuesprotected int keylength; // the length of the primary key@@ -414,12 +414,18 @@ public class HeapReader {index.remove(key);return null;}- if (MemoryControl.available() < len * 2 + keepFreeMem) {- if (!MemoryControl.request(len * 2 + keepFreeMem, true)) throw new RowSpaceExceededException(len * 2 + keepFreeMem, "HeapReader.get()"); // not enough memory available for this blob+ long memr = len + index.row().primaryKeyLength + 64;+ if (MemoryControl.available() < memr) {+ if (!MemoryControl.request(memr, true)) throw new RowSpaceExceededException(memr, "HeapReader.get()/check"); // not enough memory available for this blob}// read the key- final byte[] keyf = new byte[index.row().primaryKeyLength];+ byte[] keyf;+ try {+ keyf = new byte[index.row().primaryKeyLength];+ } catch (OutOfMemoryError e) {+ throw new RowSpaceExceededException(index.row().primaryKeyLength, "HeapReader.get()/keyf");+ }file.readFully(keyf, 0, keyf.length);if (!this.ordering.equal(key, keyf)) {// verification of the indexed access failed. we must re-read the index@@ -435,7 +441,12 @@ public class HeapReader {}// read the blob- byte[] blob = new byte[len];+ byte[] blob;+ try {+ blob = new byte[len];+ } catch (OutOfMemoryError e) {+ throw new RowSpaceExceededException(len, "HeapReader.get()/blob");+ }file.readFully(blob, 0, blob.length);return blob;diff --git a/source/net/yacy/kelondro/blob/MapHeap.java b/source/net/yacy/kelondro/blob/MapHeap.javaindex 401207639..b79dd85c0 100644--- a/source/net/yacy/kelondro/blob/MapHeap.java+++ b/source/net/yacy/kelondro/blob/MapHeap.java@@ -177,7 +177,7 @@ public class MapHeap implements Map<byte[], Map<String, String>> {synchronized (this) {// remove from cache- cache.remove(key);+ if (cache != null) cache.remove(key);// remove from fileblob.delete(key);diff --git a/source/net/yacy/kelondro/index/RowCollection.java b/source/net/yacy/kelondro/index/RowCollection.javaindex 0526ce88a..76b86c9fc 100644--- a/source/net/yacy/kelondro/index/RowCollection.java+++ b/source/net/yacy/kelondro/index/RowCollection.java@@ -276,8 +276,8 @@ public class RowCollection implements Iterable<Row.Entry>, Cloneable {if (allocram == 0) return;assert chunkcache.length < elements * rowdef.objectsize : "wrong alloc computation (1): elements * rowdef.objectsize = " + (elements * rowdef.objectsize) + ", chunkcache.length = " + chunkcache.length;assert allocram > chunkcache.length : "wrong alloc computation (2): allocram = " + allocram + ", chunkcache.length = " + chunkcache.length;- if (allocram > Integer.MAX_VALUE || !MemoryControl.request(allocram, true))- throw new RowSpaceExceededException(allocram, "RowCollection grow");+ if (allocram > Integer.MAX_VALUE || !MemoryControl.request(allocram + 32, true))+ throw new RowSpaceExceededException(allocram + 32, "RowCollection grow");try {final byte[] newChunkcache = new byte[(int) allocram]; // increase spaceSystem.arraycopy(chunkcache, 0, newChunkcache, 0, chunkcache.length);