/** Get the memory limit in MB. Return -1 if we don't know, -2 for unlimited. */ public static long getMemoryLimitMB() { long limit = getMemoryLimitBytes(); if(limit <= 0) return limit; if(limit == Long.MAX_VALUE) return -2; limit /= (1024 * 1024); if(limit > Integer.MAX_VALUE) return -1; // Seems unlikely. FIXME 2TB limit! return limit; }
private long maxDatastoreSize() { long maxMemory = NodeStarter.getMemoryLimitBytes(); if(maxMemory == Long.MAX_VALUE) return 1024*1024*1024; // Treat as don't know. if(maxMemory < 128*1024*1024) return 1024*1024*1024; // 1GB default if don't know or very small memory. // Don't use the first 100MB for slot filters. long available = maxMemory - 100*1024*1024; // Don't use more than 50% of available memory for slot filters. available = available / 2; // Slot filters are 4 bytes per slot. long slots = available / 4; // There are 3 types of keys. We want the number of { SSK, CHK, pubkey } i.e. the number of slots in each store. slots /= 3; // We return the total size, so we don't need to worry about cache vs store or even client cache. // One key of all 3 types combined uses Node.sizePerKey bytes on disk. So we get a size. return slots * Node.sizePerKey; }
private static long maxSize(){ long memory = NodeStarter.getMemoryLimitBytes(); if(memory == Long.MAX_VALUE || memory <= 0) return 1024*1024; long maxMem = Math.round(0.05*memory); long limit = Math.max(maxMem, 1024*1024); return limit; }
long memoryLimit = NodeStarter.getMemoryLimitBytes();
long overallMemoryLimit = NodeStarter.getMemoryLimitBytes(); if (overallMemoryLimit > 512 * 1024 * 1024) {