Is there a SoftHashMap in Java?

Edit (Aug. 2012): It turns out that currently the best solution are probably Guava 13.0’s Cache classes, explained on Guava’s Wiki – that’s what I’m going to use. It even supports building a SoftHashMap (see CacheBuilder.newBuilder().softKeys()), but it is probably not what you want, as Java expert Jeremy Manson explains (below you’ll find the link). … Read more

Understanding Java’s Reference classes: SoftReference, WeakReference, and PhantomReference

The Java library documentation for the java.lang.ref package characterizes the decreasing strength of the three explicit reference types. You use a SoftReference when you want the referenced object to stay alive until the host process is running low on memory. The object will not be eligible for collection until the collector needs to free memory. … Read more

Java: difference between strong/soft/weak/phantom reference

Java provides two different types/classes of Reference Objects: strong and weak. Weak Reference Objects can be further divided into soft and phantom. Strong Weak soft phantom Let’s go point by point. Strong Reference Object StringBuilder builder = new StringBuilder(); This is the default type/class of Reference Object, if not differently specified: builder is a strong … Read more

What’s the difference between SoftReference and WeakReference in Java?

From Understanding Weak References, by Ethan Nicholas: Weak references A weak reference, simply put, is a reference that isn’t strong enough to force an object to remain in memory. Weak references allow you to leverage the garbage collector’s ability to determine reachability for you, so you don’t have to do it yourself. You create a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)