Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-06-2008, 12:35 AM
Member
 
Join Date: Oct 2008
Posts: 45
priyanka.dandekar is on a distinguished road
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,

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-06-2008, 12:39 AM
Member
 
Join Date: Oct 2008
Location: US
Posts: 40
kzvi.kzvi.1 is on a distinguished road
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....

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


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

vB 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 06:16 PM
how to improve java performance sunjavaboy Advanced Java 6 06-15-2008 07:58 AM
Java performance Issues (IV) - Hardware interfacing JavaForums Java Blogs 0 01-31-2008 03:20 PM
Java performance Issues (II) - Memory JavaForums Java Blogs 0 01-30-2008 03:01 PM
Java performance Issues (I) JavaForums Java Blogs 0 01-30-2008 03:01 PM


All times are GMT +3. The time now is 09:28 AM.


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