forked from I2P_Developers/i2p.i2p
reinstate cache capacity calculation
This commit is contained in:
@@ -73,7 +73,6 @@ class EventPumper implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private static final TryCache<ByteBuffer> _bufferCache = new TryCache<>(new BufferFactory(), MAX_CACHE_SIZE);
|
||||
|
||||
/**
|
||||
* every few seconds, iterate across all ntcp connections just to make sure
|
||||
@@ -106,6 +105,8 @@ class EventPumper implements Runnable {
|
||||
MIN_BUFS = (int) Math.max(MIN_MINB, Math.min(MAX_MINB, 1 + (maxMemory / (16*1024*1024))));
|
||||
}
|
||||
|
||||
private static final TryCache<ByteBuffer> _bufferCache = new TryCache<>(new BufferFactory(), MIN_BUFS);
|
||||
|
||||
public EventPumper(RouterContext ctx, NTCPTransport transport) {
|
||||
_context = ctx;
|
||||
_log = ctx.logManager().getLog(getClass());
|
||||
|
@@ -57,11 +57,14 @@ class UDPPacket implements CDQEntry {
|
||||
private static final TryCache<UDPPacket> _packetCache;
|
||||
private static final TryCache.ObjectFactory<UDPPacket> _packetFactory;
|
||||
private static final boolean CACHE = true;
|
||||
private static final int MIN_CACHE_SIZE = 64;
|
||||
private static final int MAX_CACHE_SIZE = 256;
|
||||
static {
|
||||
if (CACHE) {
|
||||
long maxMemory = SystemVersion.getMaxMemory();
|
||||
int csize = (int) Math.max(MIN_CACHE_SIZE, Math.min(MAX_CACHE_SIZE, maxMemory / (1024*1024)));
|
||||
_packetFactory = new PacketFactory();
|
||||
_packetCache = new TryCache<>(_packetFactory, MAX_CACHE_SIZE);
|
||||
_packetCache = new TryCache<>(_packetFactory, csize);
|
||||
} else {
|
||||
_packetCache = null;
|
||||
_packetFactory = null;
|
||||
|
Reference in New Issue
Block a user