Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
small memory leak patch
Michael Peter Christen77faeada4d1d
diff --git a/source/net/yacy/crawler/data/Latency.java b/source/net/yacy/crawler/data/Latency.javaindex 9fae6ce8f..ea5b5ca12 100644--- a/source/net/yacy/crawler/data/Latency.java+++ b/source/net/yacy/crawler/data/Latency.java@@ -43,6 +43,7 @@ public class Latency {private final static int DEFAULT_AVERAGE = 300;// the map is a mapping from host names to host configurations+ private static final int mapMaxSize = 1000;private static final ConcurrentHashMap<String, Host> map = new ConcurrentHashMap<String, Host>();/**@@ -57,7 +58,7 @@ public class Latency {Host h = map.get(hosthash);if (h == null) {h = new Host(host, DEFAULT_AVERAGE, robotsCrawlDelay);- if (map.size() > 1000 || MemoryControl.shortStatus()) map.clear();+ if (map.size() > mapMaxSize || MemoryControl.shortStatus()) map.clear();map.put(hosthash, h);}}@@ -74,7 +75,7 @@ public class Latency {Host h = map.get(hosthash);if (h == null) {h = new Host(host, 500, 0);- if (map.size() > 1000 || MemoryControl.shortStatus()) map.clear();+ if (map.size() > mapMaxSize || MemoryControl.shortStatus()) map.clear();map.put(hosthash, h);} else {h.update();@@ -93,7 +94,7 @@ public class Latency {Host h = map.get(hosthash);if (h == null) {h = new Host(host, time, 0);- if (map.size() > 1000 || MemoryControl.shortStatus()) map.clear();+ if (map.size() > mapMaxSize || MemoryControl.shortStatus()) map.clear();map.put(hosthash, h);} else {h.update(time);diff --git a/source/net/yacy/repository/LoaderDispatcher.java b/source/net/yacy/repository/LoaderDispatcher.javaindex a65c4dae4..7a8b1717f 100644--- a/source/net/yacy/repository/LoaderDispatcher.java+++ b/source/net/yacy/repository/LoaderDispatcher.java@@ -65,6 +65,7 @@ import net.yacy.search.Switchboard;public final class LoaderDispatcher {+ private final static int accessTimeMaxsize = 1000;private static final ConcurrentHashMap<String, Long> accessTime = new ConcurrentHashMap<String, Long>(); // to protect targets from DDoSprivate final Switchboard sb;@@ -271,7 +272,10 @@ public final class LoaderDispatcher {}// now it's for sure that we will access the target. Remember the access time- if (host != null) accessTime.put(host, System.currentTimeMillis());+ if (host != null) {+ if (accessTime.size() > accessTimeMaxsize) accessTime.clear(); // prevent a memory leak here+ accessTime.put(host, System.currentTimeMillis());+ }// load resource from the internetResponse response = null;