<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-6098392112071095875.post3611172598996582196..comments</id><updated>2012-01-19T08:06:38.002-05:00</updated><category term='Hibernate'/><category term='Code'/><category term='Productivity'/><category term='Opinion'/><category term='Spring'/><category term='Performance'/><category term='Agile'/><category term='Java'/><category term='Scrum'/><title type='text'>Comments on Code Instructions: WeakHashMap is not a cache!  Understanding WeakRef...</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.codeinstructions.com/feeds/3611172598996582196/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html'/><author><name>Domingos Neto</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_HHFrwTieqY8/STh7yQ1m0bI/AAAAAAAAABs/8BJWpydZgZ4/S220/cruzes.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-2951693127986960512</id><published>2012-01-18T15:59:51.889-05:00</published><updated>2012-01-18T15:59:51.889-05:00</updated><title type='text'>&amp;quot;This reduces the effectiveness of the cache ...</title><content type='html'>&amp;quot;This reduces the effectiveness of the cache because you would expect the object to remain in the cache since the strong reference to it is still around&amp;quot;&lt;br /&gt;&lt;br /&gt;Ummm no. This is something you made up. Nobody would expect a cache to know that you are keeping a reference to an object. Even if the cache were strictly LRU, other threads could have queried the cache so many times that the object you retrieved would no longer be in the cache.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/2951693127986960512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/2951693127986960512'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1326920391889#c2951693127986960512' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-714915016'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-3512364556189231346</id><published>2011-05-31T22:26:18.925-04:00</published><updated>2011-05-31T22:26:18.925-04:00</updated><title type='text'>Hi,
We can implement a caching system [LRU] using ...</title><content type='html'>Hi,&lt;br /&gt;We can implement a caching system [LRU] using linkedhashmap. Please refer to the documentation in spec for details.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/3512364556189231346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/3512364556189231346'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1306895178925#c3512364556189231346' title=''/><author><name>arrun</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1964766324'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-1368772498393348501</id><published>2009-11-26T05:44:10.915-05:00</published><updated>2009-11-26T05:44:10.915-05:00</updated><title type='text'>Great article, reflects my confusion about WeakHas...</title><content type='html'>Great article, reflects my confusion about WeakHashMap being cited as a caching facility.&lt;br /&gt;&lt;br /&gt;Also thanks for the pointer to Google&amp;#39;s ReferenceMap, gotta use that instead.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/1368772498393348501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/1368772498393348501'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1259232250915#c1368772498393348501' title=''/><author><name>Matthias</name><uri>http://www.blogger.com/profile/11991040271336510502</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-332193220'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-2436804350040231700</id><published>2008-11-14T07:07:00.000-05:00</published><updated>2008-11-14T07:07:00.000-05:00</updated><title type='text'>Hi Domingos,&lt;br&gt;Your article is informative.&lt;br&gt;&lt;b...</title><content type='html'>Hi Domingos,&lt;BR/&gt;Your article is informative.&lt;BR/&gt;&lt;BR/&gt;However I wish to clarify one point.&lt;BR/&gt;&lt;BR/&gt;In the copy pasted example code snippet you say..&lt;BR/&gt;&lt;BR/&gt;    // Uh-oh, the cache got rid of the object, even though I    // still had a reference to it in the myReference1 variable!&lt;BR/&gt;&lt;BR/&gt;But you really mean that the key could be GC'd and therefore you cannot get at the value (because there is no key!) which however is still being referenced by myReference1 right?&lt;BR/&gt;&lt;BR/&gt;Bit confused here would be grateful if you could set the record straight.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/2436804350040231700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/2436804350040231700'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1226664420000#c2436804350040231700' title=''/><author><name>thaakshana</name><uri>http://www.blogger.com/profile/04340671507723909380</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-896573639'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-6425087784074662269</id><published>2008-10-28T13:46:00.000-04:00</published><updated>2008-10-28T13:46:00.000-04:00</updated><title type='text'>Interesting to know.</title><content type='html'>Interesting to know.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/6425087784074662269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/6425087784074662269'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1225215960000#c6425087784074662269' title=''/><author><name>Ros</name><uri>http://augustinsurance.blogspot.com</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1240229253'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-5597382863659324463</id><published>2008-09-23T08:46:00.000-04:00</published><updated>2008-09-23T08:46:00.000-04:00</updated><title type='text'>jodastephen:&lt;br&gt;&lt;br&gt;very good point :)</title><content type='html'>jodastephen:&lt;BR/&gt;&lt;BR/&gt;very good point :)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/5597382863659324463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/5597382863659324463'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1222173960000#c5597382863659324463' title=''/><author><name>Domingos Neto</name><uri>http://www.blogger.com/profile/16748499695622931125</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_HHFrwTieqY8/SNhkCL5y83I/AAAAAAAAABU/AtjC5jkuS04/S220/rosto2.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1013888231'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-7663585227185283297</id><published>2008-09-23T08:31:00.000-04:00</published><updated>2008-09-23T08:31:00.000-04:00</updated><title type='text'>"Please, don't copy and paste the WeakHashMap sour...</title><content type='html'>"Please, don't copy and paste the WeakHashMap source code replacing WeakReference with SoftReference"&lt;BR/&gt;&lt;BR/&gt;This would be against Sun's copyright. Please don't copy someone else's code.&lt;BR/&gt;&lt;BR/&gt;The google collections ReferenceMap follows the ideas started in Apache Commons:&lt;BR/&gt;http://commons.apache.org/collections/api/org/apache/commons/collections/ReferenceMap.html&lt;BR/&gt;&lt;BR/&gt;Note that the Apache Commons version is suitable for Java 1.4, and the Google one is generified.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/7663585227185283297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/7663585227185283297'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1222173060000#c7663585227185283297' title=''/><author><name>JodaStephen</name><uri>http://www.blogger.com/profile/01454237967846880639</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1821223591'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-7583991894479216554</id><published>2008-09-23T07:30:00.000-04:00</published><updated>2008-09-23T07:30:00.000-04:00</updated><title type='text'>Thanks for that Dimitris!</title><content type='html'>Thanks for that Dimitris!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/7583991894479216554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/7583991894479216554'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1222169400000#c7583991894479216554' title=''/><author><name>Domingos Neto</name><uri>http://www.blogger.com/profile/16748499695622931125</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://1.bp.blogspot.com/_HHFrwTieqY8/SNhkCL5y83I/AAAAAAAAABU/AtjC5jkuS04/S220/rosto2.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1013888231'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-125098337134767383</id><published>2008-09-23T05:22:00.000-04:00</published><updated>2008-09-23T05:22:00.000-04:00</updated><title type='text'>http://google-collections.googlecode.com/svn/trunk...</title><content type='html'>http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ReferenceMap.html</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/125098337134767383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/125098337134767383'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1222161720000#c125098337134767383' title=''/><author><name>Dimitris Andreou</name><uri>http://www.blogger.com/profile/07286834543482860937</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2069003562'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-7243282995494923897</id><published>2008-09-22T20:34:00.000-04:00</published><updated>2008-09-22T20:34:00.000-04:00</updated><title type='text'>Hi meadandale,&lt;br&gt;&lt;br&gt;You application of the WeakH...</title><content type='html'>Hi meadandale,&lt;BR/&gt;&lt;BR/&gt;You application of the WeakHashMap is actually a very clever one! I wouldn't have thought of it myself and I am already thinking of places where I can apply it in my own applications :)&lt;BR/&gt;&lt;BR/&gt;I do agree with you that what you described is not what is conventionally called a cache :)  A cache is a memory location where you can store data that is otherwise expensive to obtain.  I just couldn't find yet a better term for the kind of structure that you created, so, even though it can be called a cache for lack of a better name, it is not what is conventionally known by this name!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/7243282995494923897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/7243282995494923897'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1222130040000#c7243282995494923897' title=''/><author><name>Domingos Neto</name><uri>http://www.blogger.com/profile/16748499695622931125</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1013888231'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-4615326764759361047</id><published>2008-09-22T11:56:00.000-04:00</published><updated>2008-09-22T11:56:00.000-04:00</updated><title type='text'>You CAN use a weak hashmap as a temporal cache and...</title><content type='html'>You CAN use a weak hashmap as a temporal cache and I've done this before.&lt;BR/&gt;&lt;BR/&gt;In my case, I was implementing flyweight support for jfreechart, which tends to create lots of primitive wrapper objects. It was causing millions of objects to be created for every graph I created.&lt;BR/&gt;&lt;BR/&gt;I implemented a wrapper object cache using a weak hashmap so that strings and primitives would map to shared instances of wrapper objects. It allowed charts to reuse the same wrapper objects and also allowed concurrently executing threads to also share the same values.&lt;BR/&gt;&lt;BR/&gt;It RELIED on the fact that once the charts were created, the caches got purged by the GC.&lt;BR/&gt;&lt;BR/&gt;It decreased the object churn (and associated performance problems we were seeing) by better than 3 orders of magnitude.&lt;BR/&gt;&lt;BR/&gt;But, in general, you are correct in that weak hashmaps don't make good caches based on the common definition most people have for a cache.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/4615326764759361047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/3611172598996582196/comments/default/4615326764759361047'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html?showComment=1222098960000#c4615326764759361047' title=''/><author><name>meadandale</name><uri>http://www.blogger.com/profile/08599891061148310736</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-3611172598996582196' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/3611172598996582196' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1767736846'/></entry></feed>
