clear some more caches if running out of memory

pull/1/head
sixcooler 12 years ago
parent 6fc4bdddbd
commit 3a13906121

@ -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) {}
}

@ -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);

@ -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();
}
}

Loading…
Cancel
Save