@Test public void canStore1Gigs() throws Exception { for (int i = 0; i < 1000; i++) { FatObj fatty = new FatObj(r, 1024 * 1024); storage.put(fatty, "fubar"); } }
public V put(K key, V val) { WeakRef<K, V> newRef = new WeakRef<K, V>(key, refQueue, val); WeakRef<K, V> oldRef = map.put(newRef, newRef); V prev = null; if (oldRef != null) { prev = oldRef.getHardRef(); } cleanupRefQueue(); return prev; }
WeakKeyHashMap { public V put(K key, V val) { WeakRef<K, V> newRef = new WeakRef<K, V>(key, refQueue, val); WeakRef<K, V> oldRef = map.put(newRef, newRef); V prev = null; if (oldRef != null) { prev = oldRef.getHardRef(); } cleanupRefQueue(); return prev; } }
WeakKeyHashMap { public V put(K key, V val) { WeakRef<K, V> newRef = new WeakRef<K, V>(key, refQueue, val); WeakRef<K, V> oldRef = map.put(newRef, newRef); V prev = null; if (oldRef != null) { prev = oldRef.getHardRef(); } cleanupRefQueue(); return prev; } WeakKeyHashMap(); }
WeakKeyHashMap { public V put(K key, V val) { WeakRef<K, V> newRef = new WeakRef<K, V>(key, refQueue, val); WeakRef<K, V> oldRef = map.put(newRef, newRef); V prev = null; if (oldRef != null) { prev = oldRef.getHardRef(); } cleanupRefQueue(); return prev; } WeakKeyHashMap(); int size(); V put(K key, V val); V get(K key); V remove(K key); static String dumpObj(Object obj); }
WeakKeyHashMap { public V put(K key, V val) { WeakRef<K, V> newRef = new WeakRef<K, V>(key, refQueue, val); WeakRef<K, V> oldRef = map.put(newRef, newRef); V prev = null; if (oldRef != null) { prev = oldRef.getHardRef(); } cleanupRefQueue(); return prev; } WeakKeyHashMap(); int size(); V put(K key, V val); V get(K key); V remove(K key); static String dumpObj(Object obj);  }