From 72752bb50311aa16394ba612f25fdbdc5169e6d3 Mon Sep 17 00:00:00 2001
From: orbiter <orbiter@6c8d7289-2bf4-0310-a012-ef5d649a1542>
Date: Mon, 20 Aug 2007 17:36:43 +0000
Subject: [PATCH] because of a new database structure handling, the memory need
 for accessing collection objects has been reduced to 50%: - set new memory
 calculation functions for indexing process - adjusted guessed memory amount
 -> Testing needed:    try new recommended value (see performanceQueues) and
 see if OOMs occur. -> report maximum recommended value, so we can set new
 default values.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4053 6c8d7289-2bf4-0310-a012-ef5d649a1542
---
 htroot/PerformanceQueues_p.java                        | 2 +-
 source/de/anomic/index/indexCollectionRI.java          | 2 +-
 source/de/anomic/index/indexRAMRI.java                 | 4 +++-
 source/de/anomic/kelondro/kelondroCollectionIndex.java | 2 +-
 source/de/anomic/plasma/plasmaWordIndex.java           | 2 +-
 5 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java
index 0943eff06..60a883bbe 100644
--- a/htroot/PerformanceQueues_p.java
+++ b/htroot/PerformanceQueues_p.java
@@ -176,7 +176,7 @@ public class PerformanceQueues_p {
             // disallow setting of memprereq for indexer to prevent db from throwing OOMs
             prop.put("table_" + c + "_disabled", /*(threadName.endsWith("_indexing")) ? 1 :*/ 0);
             prop.put("table_" + c + "_recommendation", (threadName.endsWith("_indexing")) ? 1 : 0);
-            prop.put("table_" + c + "_recommendation_value", (threadName.endsWith("_indexing")) ? ((switchboard.wordIndex.minMem() + 2 * 1024 * 1024)/1024) : 0);
+            prop.put("table_" + c + "_recommendation_value", (threadName.endsWith("_indexing")) ? (switchboard.wordIndex.minMem() / 1024) : 0);
             c++;
         }
         prop.put("table", c);
diff --git a/source/de/anomic/index/indexCollectionRI.java b/source/de/anomic/index/indexCollectionRI.java
index ed83e4b39..c52c8aa35 100644
--- a/source/de/anomic/index/indexCollectionRI.java
+++ b/source/de/anomic/index/indexCollectionRI.java
@@ -82,7 +82,7 @@ public class indexCollectionRI implements indexRI {
     public int minMem() {
         // calculate a minimum amount of memory that is necessary to use the index
         // during runtime (after the object was initialized)
-        return collectionIndex.minMem();
+        return 100 * 1024 /* overhead here */ + collectionIndex.minMem();
     }
 
     public synchronized kelondroCloneableIterator wordContainers(String startWordHash, boolean rot) {
diff --git a/source/de/anomic/index/indexRAMRI.java b/source/de/anomic/index/indexRAMRI.java
index 11d289ecd..d5005b696 100644
--- a/source/de/anomic/index/indexRAMRI.java
+++ b/source/de/anomic/index/indexRAMRI.java
@@ -95,7 +95,9 @@ public final class indexRAMRI implements indexRI {
     }
 
     public int minMem() {
-        return 1024*1024;
+        // there is no specific large array that needs to be maintained
+        // this value is just a guess of the possible overhead
+        return 100 * 1024; // 100 kb
     }
     
     public synchronized long getUpdateTime(String wordHash) {
diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.java
index 6a2a7598e..06d18b4ec 100644
--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java
+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java
@@ -276,7 +276,7 @@ public class kelondroCollectionIndex {
         // this is computed by the size of the biggest used collection
         // this must be multiplied with the payload size
         // and doubled for necessary memory transformation during sort operation
-        return (int) (2 * arrayCapacity(arrays.size() - 1) * this.payloadrow.objectsize * kelondroRowSet.growfactor);
+        return (int) (arrayCapacity(arrays.size() - 1) * this.payloadrow.objectsize * kelondroRowSet.growfactor);
     }
     
     private void array_remove(
diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java
index d80ae0ecc..233b35e55 100644
--- a/source/de/anomic/plasma/plasmaWordIndex.java
+++ b/source/de/anomic/plasma/plasmaWordIndex.java
@@ -91,7 +91,7 @@ public final class plasmaWordIndex implements indexRI {
     }
 
     public int minMem() {
-        return 2*1024*1024 /* indexing overhead */ + dhtOutCache.minMem() + dhtInCache.minMem() + collections.minMem();
+        return 1024*1024 /* indexing overhead */ + dhtOutCache.minMem() + dhtInCache.minMem() + collections.minMem();
     }
 
     public int maxURLinDHTOutCache() {