tag:blogger.com,1999:blog-9150561117329868491.post3017343900135618454..comments2023-10-08T20:48:43.878+05:30Comments on My Journey Through IT: Understanding Java ReferencesDinuka Arseculeratnehttp://www.blogger.com/profile/13924080326710656628noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-9150561117329868491.post-6927676579240716642016-04-15T20:18:56.217+05:302016-04-15T20:18:56.217+05:30Great post !!
In case you need some books you can...Great post !!<br /><br />In case you need some books you can check out this <a href="http://java-books.com" rel="nofollow">list</a>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9150561117329868491.post-65141111972490385642012-01-17T20:26:14.909+05:302012-01-17T20:26:14.909+05:30Hi Craig
I beg your pardon but why would a weak r...Hi Craig<br /><br />I beg your pardon but why would a weak reference an ideal implementation for in memory cache? Shouldn't it be the soft reference?? I mean what is the point of building a cache and loosing it in the next GC run(given there is no strong reference to the cache). I would ideally like my cache to stay in memory as long as possible and should be thrown out(garbage collected) deckingrajhttps://www.blogger.com/profile/15939924763815511872noreply@blogger.comtag:blogger.com,1999:blog-9150561117329868491.post-4926686095470023652012-01-14T08:21:27.192+05:302012-01-14T08:21:27.192+05:30Hi Craig,
Thank you for the comprehensive comment...Hi Craig,<br /><br />Thank you for the comprehensive comment on the subject matter. I understand your point of view. One concern im still having is Craig that in my sample program i have given above, why did the JVM crash when i was using soft reference and did not crash when i used weak reference? i was running with a very low -xms and -xmx, so i was expecting the soft reference to be gc'd Dinuka Arseculeratnehttps://www.blogger.com/profile/13924080326710656628noreply@blogger.comtag:blogger.com,1999:blog-9150561117329868491.post-60378323860704205212012-01-14T08:09:38.018+05:302012-01-14T08:09:38.018+05:30For caching, soft references are often better as t...For caching, soft references are often better as they won't be gc'd until the JVM needs to free memory for something else.<br /><br />Weak references are more useful for preventing various classes of memory leak (classloader leaks in modular systems, problems caused by complex circular references, etc). They're also good when you want to store info about an object whose lifecycle you Craig Ringerhttp://blog.ringerc.id.au/noreply@blogger.comtag:blogger.com,1999:blog-9150561117329868491.post-31146121033096697272012-01-13T13:26:05.100+05:302012-01-13T13:26:05.100+05:30Hi,
first of all thank you taking the time to leav...Hi,<br />first of all thank you taking the time to leave a comment. Regarding this, one use case i saw was when you need to implement an in-memory cache within your application. Say in such a case where your application is running out of memory, and if you can live with the fact of your cache being removed from memory which can later be re-instantiated, and that performance impact is bearable forDinuka Arseculeratnehttps://www.blogger.com/profile/13924080326710656628noreply@blogger.comtag:blogger.com,1999:blog-9150561117329868491.post-53590846629817491552012-01-13T11:59:42.402+05:302012-01-13T11:59:42.402+05:30Is there any other use of weak references other th...Is there any other use of weak references other than making <a href="http://javarevisited.blogspot.com/2011/04/garbage-collection-in-java.html" rel="nofollow">Object on weakhahsmap eligible for garbage collection</a>. I quite like the concept but haven't yet find any other suitable use.Enum Javahttp://javarevisited.blogspot.com/2011/08/enum-in-java-example-tutorial.htmlnoreply@blogger.com