Aneesh Vijendran wrote:Hi Vishwas,
I am not sure, what kind of data are you storing in the hashtable. Anyhow it's not a good idea, if your idea is to store them all in a go inside teh hashmap. Or if it is to be displayed why not impliment some pagination ?
Why don't you try using Weakrefernce?
http://java.sun.com/j2se/1.4.2/docs/api/java/util/WeakHashMap.html
Cheers
Aneesh
I don't think a WeakReference is a solution to the problem unless keys are often discarded. Also, for 5000 objects to cause an OOM error those objects need to be quite big. You can start by using the -Xmx JVM command line parameter to increase your app's heap size. If that is not possible you'll have to explore ways to make the objects you are storing use less memory. The HashMap itself is not the issue with so few objects actually being mapped. If you cannot make your objects use less memory and they are also stored somewhere else (database, disk) consider using lazy loading (load the object when the data is retrieved, dump the object if more than X other more recently requested objects are being cached, etc.).
Remon