orgecc


WeakHashMap usage and problems

Posted in java by elifarley on the October 31st, 2007

Since a WeakHashMap should not be used as a cache (because its keys will be garbage collected too soon), what is it good for ?

- to keep information about objects without preventing them from being GC’d (according to Scott Vachalek).

Bob Lee tells us that “the most common use case for WHM is to use Class instances as keys” (He also points us to the Google Collections Library).

These comments and other really interesting information can be found at a post titled “Why WeakHashMap Sucks“, by Dr. Cliff Click, Chief JVM Architect of Azul Systems.

But since a SoftHashMap (a Map using SoftReference instead of WeakReference) would be useful as a cache, why has Sun decided to provide a WeakHashMap instead of a SoftHashMap ?

Here we have some more related links:

WordPress database error: [Table './orgecc_wordpress/wp_comments' is marked as crashed and should be repaired]
SELECT * FROM wp_comments WHERE comment_post_ID = '12' AND comment_approved = '1' ORDER BY comment_date

Leave a Reply


WP-Highlight