<?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.post385167265040721281..comments</id><updated>2011-12-27T11:30:40.792-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: Weak Object Pools with WeakHashMap</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.codeinstructions.com/feeds/385167265040721281/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.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>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-6434025156902169348</id><published>2011-12-19T11:41:10.028-05:00</published><updated>2011-12-19T11:41:10.028-05:00</updated><title type='text'>Yep, and it works nicely. Hence why I got confused...</title><content type='html'>Yep, and it works nicely. Hence why I got confused when I thought this article was the same as my usecase. I thought I must be missing something, and indeed I was, some glasses ;)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/6434025156902169348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/6434025156902169348'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1324312870028#c6434025156902169348' title=''/><author><name>KieronW</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/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1663461261'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-7821341051828932690</id><published>2011-12-19T10:39:10.859-05:00</published><updated>2011-12-19T10:39:10.859-05:00</updated><title type='text'>Hi KieronW,

This is exactly what the WeakHashMap ...</title><content type='html'>Hi KieronW,&lt;br /&gt;&lt;br /&gt;This is exactly what the WeakHashMap is for!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/7821341051828932690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/7821341051828932690'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1324309150859#c7821341051828932690' 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='32' height='30' src='http://2.bp.blogspot.com/_HHFrwTieqY8/STh7yQ1m0bI/AAAAAAAAABs/8BJWpydZgZ4/S220/cruzes.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' 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-6155407368721950432</id><published>2011-12-19T05:44:03.710-05:00</published><updated>2011-12-19T05:44:03.710-05:00</updated><title type='text'>Ah, sorry. I have totally confused the situation b...</title><content type='html'>Ah, sorry. I have totally confused the situation by not reading your second article properly.&lt;br /&gt;What I was trying to do is create basically a short-term cache, not an object pool like you&lt;br /&gt;are doing here.&lt;br /&gt;&lt;br /&gt;Basically this:&lt;br /&gt;&lt;br /&gt;String[] expressionStrs = createExpressions(); // a large number, with many duplicates&lt;br /&gt;for (String expressionStr : expressionStrs) {&lt;br /&gt;  Expression expression = expensiveParse(expressionStr);&lt;br /&gt;  result.add(expression);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;So what I was trying to do is use a cheap WeakHashMap[String,Expression] cache that only parses&lt;br /&gt;expressions if it is genuinely different to previous ones. Once the expressionStrs falls out of&lt;br /&gt;scope, and GC runs, my WeakHashMap becomes empty. Then, once I have finished with my expressions,&lt;br /&gt;I get all my memory back.&lt;br /&gt;&lt;br /&gt;Cheap (I don&amp;#39;t want stuff to stick around like SoftReferences do) and easy to manage.&lt;br /&gt;&lt;br /&gt;But of course, totally different to what you are doing here. So I guess this was more appropriate&lt;br /&gt;for your first article - WeakHashMap can be used for a very specific type of cache. :)&lt;br /&gt;&lt;br /&gt;Anyway thanks, I found your article very informative.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/6155407368721950432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/6155407368721950432'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1324291443710#c6155407368721950432' title=''/><author><name>KieronW</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/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1946866314'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-7739412484341972604</id><published>2011-12-16T12:41:55.432-05:00</published><updated>2011-12-16T12:41:55.432-05:00</updated><title type='text'>Hi KieronW,

You can run this simple test to see w...</title><content type='html'>Hi KieronW,&lt;br /&gt;&lt;br /&gt;You can run this simple test to see what I&amp;#39;m talking about:&lt;br /&gt;&lt;br /&gt;WeakHashMap&amp;lt;String, String&amp;gt; map = new WeakHashMap&amp;lt;String, String&amp;gt;();&lt;br /&gt;        &lt;br /&gt;        String value1 = new String(&amp;quot;value1&amp;quot;);&lt;br /&gt;&lt;br /&gt;        map.put(value1, value1);&lt;br /&gt;        &lt;br /&gt;        System.gc();&lt;br /&gt;&lt;br /&gt;        System.out.println(map.get(&amp;quot;value1&amp;quot;));&lt;br /&gt;        &lt;br /&gt;        value1 = null;&lt;br /&gt;&lt;br /&gt;        System.gc();&lt;br /&gt;        System.out.println(map.get(&amp;quot;value1&amp;quot;));&lt;br /&gt;&lt;br /&gt;This will print:&lt;br /&gt;value1&lt;br /&gt;value1&lt;br /&gt;&lt;br /&gt;Which means the second call to System.gc() did not clear the map even though you cleared the strong reference in the previous line.&lt;br /&gt;&lt;br /&gt;Now if you do this:&lt;br /&gt;&lt;br /&gt;WeakHashMap&amp;lt;String, WeakReference&amp;lt;String&amp;gt;&amp;gt; map = new WeakHashMap&amp;lt;String, WeakReference&amp;lt;String&amp;gt;&amp;gt;();&lt;br /&gt;        &lt;br /&gt;        String value1 = new String(&amp;quot;value1&amp;quot;);&lt;br /&gt;&lt;br /&gt;        map.put(value1, new WeakReference&amp;lt;String&amp;gt;(value1));&lt;br /&gt;        &lt;br /&gt;        System.gc();&lt;br /&gt;&lt;br /&gt;        System.out.println(map.get(&amp;quot;value1&amp;quot;).get());&lt;br /&gt;        &lt;br /&gt;        value1 = null;&lt;br /&gt;&lt;br /&gt;        System.gc();        &lt;br /&gt;        WeakReference&amp;lt;String&amp;gt; wref = map.get(&amp;quot;value1&amp;quot;);&lt;br /&gt;        String ref = null;&lt;br /&gt;        if (wref != null) {&lt;br /&gt;            ref = wref.get();&lt;br /&gt;        }&lt;br /&gt;        System.out.println(ref);&lt;br /&gt;&lt;br /&gt;Then you will get:&lt;br /&gt;&lt;br /&gt;value1&lt;br /&gt;null</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/7739412484341972604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/7739412484341972604'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1324057315432#c7739412484341972604' 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='32' height='30' src='http://2.bp.blogspot.com/_HHFrwTieqY8/STh7yQ1m0bI/AAAAAAAAABs/8BJWpydZgZ4/S220/cruzes.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' 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-8321386564441325921</id><published>2011-12-16T12:14:55.816-05:00</published><updated>2011-12-16T12:14:55.816-05:00</updated><title type='text'>Thanks for the quick answer! I was quite confused ...</title><content type='html'>Thanks for the quick answer! I was quite confused by the behaviour, so I had a look in the WeakHashMap class. It looks like it does get rid of map entries - done in the expungeStaleEntries() method - but it seems it only ever does it when there are operations performed on the map (and after keys have been GC&amp;#39;ed). However, if your map is in constant use, it does look like the values are also cleared out, and it uses the ReferenceQueue for this.&lt;br /&gt;&lt;br /&gt;I could be wrong here, so I&amp;#39;ll have a look at the weekend and see if I can verify it in code.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/8321386564441325921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/8321386564441325921'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1324055695816#c8321386564441325921' title=''/><author><name>KieronW</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/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1946866314'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-4138432408997206451</id><published>2011-12-16T12:00:23.093-05:00</published><updated>2011-12-16T12:00:23.093-05:00</updated><title type='text'>Hi KieronW,

We have to wrap the object in a WeakR...</title><content type='html'>Hi KieronW,&lt;br /&gt;&lt;br /&gt;We have to wrap the object in a WeakReference because if we didn&amp;#39;t, then there would be a strong reference to that object and it would never be garbage collected.&lt;br /&gt;&lt;br /&gt;Remember the WeakHashMap useas WeakReferences for the keys, but strong references for the values.  The garbage collector decides whether to garbage collect an object based on the strongest type of reference to that object.  In this case, every object in the map would have a strong reference pointing at it, so nothing would be garbage collected.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/4138432408997206451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/4138432408997206451'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1324054823093#c4138432408997206451' 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='32' height='30' src='http://2.bp.blogspot.com/_HHFrwTieqY8/STh7yQ1m0bI/AAAAAAAAABs/8BJWpydZgZ4/S220/cruzes.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' 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-3804506494977382080</id><published>2011-12-16T04:14:02.315-05:00</published><updated>2011-12-16T04:14:02.315-05:00</updated><title type='text'>Hi there. Just one question. Why are you wrapping ...</title><content type='html'>Hi there. Just one question. Why are you wrapping the objects in a WeakReference? Wouldn&amp;#39;t the whole map entry get discarded given the keys are weak?&lt;br /&gt;&lt;br /&gt;I ask particularly because on Oracle&amp;#39;s website they seem to imply that this is only needed if your values refer to your keys (and hence hold a strong reference to them, and the entry would never be discarded)?&lt;br /&gt;&lt;br /&gt;http://docs.oracle.com/javase/6/docs/api/java/util/WeakHashMap.html</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/3804506494977382080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/3804506494977382080'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1324026842315#c3804506494977382080' title=''/><author><name>KieronW</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/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1981760203'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-7930486164630536436</id><published>2011-04-18T21:56:22.323-04:00</published><updated>2011-04-18T21:56:22.323-04:00</updated><title type='text'>Looks like you misread the code Scott.
The *values...</title><content type='html'>Looks like you misread the code Scott.&lt;br /&gt;The *values* are being wrapped in a WeakReference, not the keys.&lt;br /&gt;&lt;br /&gt;If you just put the object itself in the map with map.put(object, object) then there would be a strong reference to object as the WeakHashMap class only wraps keys in WeakReferences</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/7930486164630536436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/7930486164630536436'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1303178182323#c7930486164630536436' 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/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1612223324'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-3455232211687981612</id><published>2011-04-08T11:25:47.899-04:00</published><updated>2011-04-08T11:25:47.899-04:00</updated><title type='text'>I know this is an old post, but I think it&amp;#39;s w...</title><content type='html'>I know this is an old post, but I think it&amp;#39;s worth noting for anyone else that comes across it that the WeakHashMap class uses WeakReference objects internally. By wrapping the key in a WeakReference object yourself you are just adding unnecessary overhead. Each key you set will end up being a WeakReference object pointing to a WeakReferenceObject pointing to the actual key.&lt;br /&gt;&lt;br /&gt;The contents of the replace function should be more like:&lt;br /&gt;&lt;br /&gt;      Object current = map.get(object);&lt;br /&gt;      if(current != null)&lt;br /&gt;        return current;&lt;br /&gt;      map.put(object, object);&lt;br /&gt;      return object;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/3455232211687981612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/3455232211687981612'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1302276347899#c3455232211687981612' title=''/><author><name>Scot</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/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1081518971'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-4064480815312426614</id><published>2009-08-28T18:06:48.407-04:00</published><updated>2009-08-28T18:06:48.407-04:00</updated><title type='text'>Nice, I liked the auto cleanup that you earn here....</title><content type='html'>Nice, I liked the auto cleanup that you earn here. I&amp;#39;m sure I&amp;#39;ll use it someday.&lt;br /&gt;&lt;br /&gt;Just a small comment about the need to use this for Integer caching, the Integer class already implements a small cache for the frequent -127-128 value. I&amp;#39;ve written about it here in &lt;a href="http://www.javatuning.com/saving-on-memory-the-valueof-method/" rel="nofollow"&gt;my blog&lt;/a&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/4064480815312426614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/4064480815312426614'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1251497208407#c4064480815312426614' title=''/><author><name>Gili Nachum</name><uri>http://www.blogger.com/profile/16996461994293511014</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/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-132143578'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-2332347687492488640</id><published>2008-11-18T06:30:00.000-05:00</published><updated>2008-11-18T06:30:00.000-05:00</updated><title type='text'>it's very good.but i have a doubt that if the Weak...</title><content type='html'>it's very good.but i have a doubt that if the WeakHahMap object is garbage collected or else if it takes more memory then.sorry if iam foolish</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/2332347687492488640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/2332347687492488640'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1227007800000#c2332347687492488640' 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/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1247301659'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-74108581941673883</id><published>2008-09-29T19:09:00.000-04:00</published><updated>2008-09-29T19:09:00.000-04:00</updated><title type='text'>Hi Felipe, it surely doesn't sound stupid.  In tha...</title><content type='html'>Hi Felipe, it surely doesn't sound stupid.  In that example, it is true that there wouldn't be any difference between using a HashSet or a WeakObjectPool. I wrote the example to be as simple as possible on purpose in order to improve readability and it turns out I simplified it so much that the benefit wasn't clear.&lt;BR/&gt;&lt;BR/&gt;To really take advantage of the instance pool you would have to make it a singleton so that you can reuse instances between unrelated method invocations.  It would be even better to make it thread safe and then you can share the same instance pool among threads.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/74108581941673883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/74108581941673883'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1222729740000#c74108581941673883' 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/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' 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-3636856785656454301</id><published>2008-09-26T17:07:00.000-04:00</published><updated>2008-09-26T17:07:00.000-04:00</updated><title type='text'>Sorry if this sounds stupid, but what would be the...</title><content type='html'>Sorry if this sounds stupid, but what would be the difference, on the CSV example, of having a Weak Object Pool over a HashSet, for instance?&lt;BR/&gt;&lt;BR/&gt;I understand that the key benefit would be if you use all the values from the CSV while processing and, later on, you no longer reference them all, allowing the weak references to be collected.&lt;BR/&gt;&lt;BR/&gt;Am I right or missing something :) ?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/3636856785656454301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/385167265040721281/comments/default/3636856785656454301'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html?showComment=1222463220000#c3636856785656454301' title=''/><author><name>Felipe Coury</name><uri>http://www.blogger.com/profile/17312733589972777822</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://bp0.blogger.com/_xteBwnVqSzM/SDO3QpOVuXI/AAAAAAAABLs/HEgNiPsqwiI/S220/felipe_avatar.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/09/instance-pools-with-weakhashmap.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-385167265040721281' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/385167265040721281' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1393424619'/></entry></feed>
