• Post Reply Bookmark Topic Watch Topic
  • New Topic

HashTable causing Out Of Memory Exception  RSS feed

 
Vimal Kumar Venugopal
Ranch Hand
Posts: 43
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Rangers,

I have an application that fetches records from a DB depending on user entered data and storing it in Hashtable in the form of String(key), Hashtable(value).
This hash table will be used in the application any time as long as the client is logged in.

Now my problem is, some customers have done a lot of transactions that the hash table becomes so huge and finally Tomcat crashes. Could someone please help me on a solution/workaround for this problem...

Thanks in Advance..
Ron
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it really necessary to keep all that data in memory? What is the data, transactions that a customer has done? Maybe you should redesign your application so that it doesn't keep all that data in memory. Just get the data you need from the database when it is necessary.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron Fields wrote:Howdy Rangers,

I have an application that fetches records from a DB depending on user entered data and storing it in Hashtable in the form of String(key), Hashtable(value).
This hash table will be used in the application any time as long as the client is logged in.

Now my problem is, some customers have done a lot of transactions that the hash table becomes so huge and finally Tomcat crashes. Could someone please help me on a solution/workaround for this problem...

Thanks in Advance..
Ron

Restrict the size of your cache. Once it reaches a certain size you have to delete one or more records from it. If that record is needed again in the future then you have to fetch it from the database again.
The skill is in deciding what records to delete from the cache. Least Recently Used is a commonly used algorithm.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!