diff --git a/core/java/src/net/i2p/data/Hash.java b/core/java/src/net/i2p/data/Hash.java index 23d466d6854e34db37b02151099f2583e664d9fd..555b00e2278b2e3ad3171458975198224e4b34a6 100644 --- a/core/java/src/net/i2p/data/Hash.java +++ b/core/java/src/net/i2p/data/Hash.java @@ -104,4 +104,11 @@ public class Hash extends SimpleDataStructure { } return _base64ed; } + + /** + * @since 0.9.17 + */ + public static void clearCache() { + _cache.clear(); + } } diff --git a/core/java/src/net/i2p/data/PublicKey.java b/core/java/src/net/i2p/data/PublicKey.java index ae5179ae42b33ea08638912524bbc34e1cd73eec..aeb9e0096b0816cbc8d4127b66cbd669e39ae13b 100644 --- a/core/java/src/net/i2p/data/PublicKey.java +++ b/core/java/src/net/i2p/data/PublicKey.java @@ -68,4 +68,11 @@ public class PublicKey extends SimpleDataStructure { public int length() { return KEYSIZE_BYTES; } + + /** + * @since 0.9.17 + */ + public static void clearCache() { + _cache.clear(); + } } diff --git a/core/java/src/net/i2p/data/SDSCache.java b/core/java/src/net/i2p/data/SDSCache.java index 9fecb6a14f6b566d3c8ebc28684d91b160ad6234..ab77680149d7380150d2cbd7dad3e05f1ef4ab70 100644 --- a/core/java/src/net/i2p/data/SDSCache.java +++ b/core/java/src/net/i2p/data/SDSCache.java @@ -91,9 +91,16 @@ public class SDSCache<V extends SimpleDataStructure> { */ private class Shutdown implements Runnable { public void run() { - synchronized(_cache) { - _cache.clear(); - } + clear(); + } + } + + /** + * @since 0.9.17 + */ + public void clear() { + synchronized(_cache) { + _cache.clear(); } } diff --git a/core/java/src/net/i2p/data/SigningPublicKey.java b/core/java/src/net/i2p/data/SigningPublicKey.java index 50dba721379b2d5cffd2d2444abe12668e037096..386deadac340b98ed2a2dc35456cf9198d041795 100644 --- a/core/java/src/net/i2p/data/SigningPublicKey.java +++ b/core/java/src/net/i2p/data/SigningPublicKey.java @@ -193,4 +193,11 @@ public class SigningPublicKey extends SimpleDataStructure { buf.append(']'); return buf.toString(); } + + /** + * @since 0.9.17 + */ + public static void clearCache() { + _cache.clear(); + } } diff --git a/history.txt b/history.txt index ac488f87fe13060811fbeca56a6a68300c27b311..bfb03b9ad064d3c4c21e76f0aa97fe3374e59989 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,5 @@ 2014-11-12 zzz + * Data: Clear more caches when under memory pressure and at shutdown * Plugins: Fix bug in stopping a ClientApp plugin with $parameters in the args 2014-11-09 zzz diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index bb597d2e2e795c1d5a9bbc58d63e34b0720114c4..ab8e7c38b8f0bb8e67d3a504c7a22e41839a5291 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -25,14 +25,18 @@ import java.util.concurrent.ConcurrentHashMap; import gnu.getopt.Getopt; +import net.i2p.crypto.SigUtil; import net.i2p.data.Base64; import net.i2p.data.Certificate; import net.i2p.data.DataFormatException; import net.i2p.data.DataHelper; import net.i2p.data.Destination; -import net.i2p.data.router.RouterInfo; +import net.i2p.data.Hash; +import net.i2p.data.PublicKey; import net.i2p.data.SigningPrivateKey; +import net.i2p.data.SigningPublicKey; import net.i2p.data.i2np.GarlicMessage; +import net.i2p.data.router.RouterInfo; import net.i2p.router.message.GarlicMessageHandler; import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade; import net.i2p.router.startup.CreateRouterInfoJob; @@ -346,6 +350,10 @@ public class Router implements RouterClock.ClockShiftListener { SimpleByteCache.clearAll(); Destination.clearCache(); Translate.clearCache(); + Hash.clearCache(); + PublicKey.clearCache(); + SigningPublicKey.clearCache(); + SigUtil.clearCaches(); } /**