use less memory for md5 cache

pull/1/head
Michael Peter Christen 13 years ago
parent f32de94723
commit 1addbc792c

@ -56,10 +56,11 @@ public class Digest {
public static BlockingQueue<MessageDigest> digestPool = new LinkedBlockingDeque<MessageDigest>();
private static final int md5CacheSize = Math.max(100000, Math.min(1000000, (int) (MemoryControl.available() / 40000L)));
private static final int md5CacheSize = Math.max(1000, Math.min(1000000, (int) (MemoryControl.available() / 50000L)));
private static ARC<String, byte[]> md5Cache = null;
static {
try {
Log.logInfo("Digest", "creating hash cache of size " + md5CacheSize);
md5Cache = new ConcurrentARC<String, byte[]>(md5CacheSize, Math.max(8, 2 * Runtime.getRuntime().availableProcessors()));
} catch (final OutOfMemoryError e) {
md5Cache = new ConcurrentARC<String, byte[]>(1000, Math.max(2, Runtime.getRuntime().availableProcessors()));

Loading…
Cancel
Save