Not really. You will find that they are garbage collected much sooner than you want. The solution to your problem is probably caching -- a simple LRU cache is likely to do fine. Rather than allowing your data set to grow indefinitely, you cache up to a fixed number of documents or words (I don't know which, your problem isn't fully clear to me). When you need to put new content in your cache, you simply junk the least recently used item(s) to make room. A LinkedList can keep track of the items.Originally posted by bipin deshpande:
Can soft references be of any use in this scenario?
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Peter den Haan:
A LinkedList can keep track of the items.
- Peter
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
And please, don't use Hashtable in new code if you can avoid it. Or Vector or Enumeration for that matter. Use the Collections classes instead (HashMap, ArrayList, LinkedList, etc, programming against the Map, List, etc interfaces wherever possible).Originally posted by bipin deshpande:
iIs it useful instead of hashtable ?
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Peter den Haan:
And please, don't use Hashtable in new code if you can avoid it. Or Vector or Enumeration for that matter. Use the Collections classes instead (HashMap, ArrayList, LinkedList, etc, programming against the Map, List, etc interfaces wherever possible).
There is really no good reason to use Hashtable and friends, and a few very good ones not to.
- Peter
Originally posted by Mark Herschberg:
Um, so what are the good reasons not to [use Vector, Hashtable and friends]?
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by bipin deshpande:
hi
i am writing a search engine.I m loading pointers to words in index files in memory....
Originally posted by bipin deshpande:
I have completed my application using jdk1.3. So if i have to use LinkedHashMap I have to start from scratch.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |