Skip to content

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

clear some more caches if running out of memory

sixcooler3a1390612197
diff --git a/source/net/yacy/cora/protocol/Domains.java b/source/net/yacy/cora/protocol/Domains.java
index 98a162057..ca277c12a 100644
--- a/source/net/yacy/cora/protocol/Domains.java
+++ b/source/net/yacy/cora/protocol/Domains.java
@@ -824,7 +824,11 @@ public class Domains {
}
public static void clear() {
- try {globalHosts.clear();} catch (IOException e) {}
+ try {
+ globalHosts.clear();
+ NAME_CACHE_HIT.clear();
+ NAME_CACHE_MISS.clear();
+ } catch (IOException e) {}
}
diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.java
index 61ec2bd28..f6ca16053 100644
--- a/source/net/yacy/repository/Blacklist.java
+++ b/source/net/yacy/repository/Blacklist.java
@@ -307,6 +307,13 @@ public class Blacklist {
return size;
}
+ public void clearblacklistCache() {
+ final Iterator<BlacklistType> iter = this.cachedUrlHashs.keySet().iterator();
+ while (iter.hasNext()) {
+ this.cachedUrlHashs.get(iter.next()).clear();
+ }
+ }
+
public boolean hashInBlacklistedCache(final BlacklistType blacklistType, final byte[] urlHash) {
HandleSet s = getCacheUrlHashsSet(blacklistType);
return s != null && s.has(urlHash);
diff --git a/source/net/yacy/search/ResourceObserver.java b/source/net/yacy/search/ResourceObserver.java
index 1f72f0c30..24727c5a5 100644
--- a/source/net/yacy/search/ResourceObserver.java
+++ b/source/net/yacy/search/ResourceObserver.java
@@ -26,8 +26,11 @@ package net.yacy.search;
import java.io.File;
+import net.yacy.cora.document.WordCache;
+import net.yacy.cora.protocol.Domains;
import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.util.MemoryControl;
+import net.yacy.search.query.SearchEventCache;
public class ResourceObserver {
@@ -85,7 +88,13 @@ public class ResourceObserver {
this.sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, true);
}
if (this.normalizedMemoryFree.compareTo(Space.HIGH) < 0 ) {
+ // clear some caches - @all: are there more of these, we could clear here?
this.sb.index.fulltext().clearCache();
+ SearchEventCache.cleanupEvents(true);
+ this.sb.trail.clear();
+ Switchboard.urlBlacklist.clearblacklistCache();
+ WordCache.clear();
+ Domains.clear();
}
}