Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-05-2008, 11:35 PM
Member
 
Join Date: Oct 2008
Posts: 68
Rep Power: 0
priyanka.dandekar is on a distinguished road
Thumbs up How can we Use SoftReference in Java for better performance
I have heard that with the use of SoftReference we can build faster and efficient cache.

I have no clue how it can be done, We are trying to build a HashMap based cache, I am just thinking of utilizing SoftReference based cache to have memory efficient implementation.

Can someone please suggest how I can do it?

Any example code or links would be really helpful.

Also let me know is it really worth doing ? Or a simple HashMap based cache is better to use?

____________________________________________
Cooking is Fun
__________________
Cheers,
Eat Healthy Stay Fit
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-05-2008, 11:39 PM
Member
 
Join Date: Oct 2008
Location: US
Posts: 58
Rep Power: 0
kzvi.kzvi.1 is on a distinguished road
Default
SoftReference are good way to implement memory efficient cache as the Java Specification says that Garbage collector will clear all soft references before throwing OutofMemoryError.

Code will definitely become more complex then a simple HashMap cache, so if you are going to build a really memory consuming cache then you can utilize a SoftReference based cache.

Here is an example of [ Cache Using SoftReference ]

There are more ways to implement reference queue clean up logic. May be other people on forum can also give input on the same.

____________________________________________
Software Wiki
__________________
Have fun....
JAVA FAQs
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Performance Ideas developer321 Advanced Java 4 06-28-2008 05:16 PM
how to improve java performance sunjavaboy Advanced Java 6 06-15-2008 06:58 AM
Java performance Issues (IV) - Hardware interfacing JavaForums Java Blogs 0 01-31-2008 02:20 PM
Java performance Issues (II) - Memory JavaForums Java Blogs 0 01-30-2008 02:01 PM
Java performance Issues (I) JavaForums Java Blogs 0 01-30-2008 02:01 PM


All times are GMT +2. The time now is 05:59 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org