public void add(Object atom) { synchronized (buckets) { if (pos >= bucket_size || buckets.size() == 0) { buckets.put(new Object[bucket_size]); pos = 0; } buckets.peekBack()[pos++] = atom; } }
public void memoryUsageLow(long usedMemory, long maxMemory) { // System.out.println("FREE COLD ATOMS START " + Runtime.getRuntime().freeMemory() + " - // " + buckets.size()); synchronized (buckets) { int cnt = buckets.size() / evictFactor; if (cnt == 0) cnt = buckets.size() > 0 ? 1 : 0; while (cnt-- > 0) buckets.fetch(); } // 2012.02.02 System.gc(); // System.out.println("FREE COLD ATOMS END " + Runtime.getRuntime().freeMemory() + " - " // + buckets.size()); }
public int size() { return bucket_size * buckets.size(); }
/** * @param capacity * @param bucket_size */ public ColdAtoms(int bucket_size) { this.bucket_size = bucket_size; buckets.put(new Object[bucket_size]); }