Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

keep more free mem

orbiterb887f4a116d7
diff --git a/source/de/anomic/kelondro/blob/BLOBArray.java b/source/de/anomic/kelondro/blob/BLOBArray.java
index 499ddda4d..f87d5c97e 100755
--- a/source/de/anomic/kelondro/blob/BLOBArray.java
+++ b/source/de/anomic/kelondro/blob/BLOBArray.java
@@ -64,7 +64,7 @@ public class BLOBArray implements BLOB {
*/
public static final long oneMonth = 1000L * 60L * 60L * 24L * 365L / 12L;
- public static final long oneGigabyte = 1024 * 1024 * 1024;
+ public static final long oneGigabyte = 1024L * 1024L * 1024L;
private int keylength;
private ByteOrder ordering;
diff --git a/source/de/anomic/kelondro/blob/HeapReader.java b/source/de/anomic/kelondro/blob/HeapReader.java
index 7459d4796..c7f4ec534 100644
--- a/source/de/anomic/kelondro/blob/HeapReader.java
+++ b/source/de/anomic/kelondro/blob/HeapReader.java
@@ -45,6 +45,8 @@ import de.anomic.kelondro.util.Log;
public class HeapReader {
+ public final static long keepFreeMem = 20 * 1024 * 1024;
+
protected int keylength; // the length of the primary key
protected LongHandleIndex index; // key/seek relation for used records
protected Gap free; // set of {seek, size} pairs denoting space and position of free records
@@ -234,8 +236,8 @@ public class HeapReader {
// access the file and read the container
file.seek(pos);
final int len = file.readInt() - index.row().primaryKeyLength;
- if (MemoryControl.available() < len) {
- if (!MemoryControl.request(len, true)) return null; // not enough memory available for this blob
+ if (MemoryControl.available() < len * 2 + keepFreeMem) {
+ if (!MemoryControl.request(len * 2 + keepFreeMem, true)) return null; // not enough memory available for this blob
}
// read the key