• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need to design a solution for effective and fast memory utilization

 
john sal
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone help me I am looking for a solution to a problem. Problem description is as follows:

We have a data model like:

name
City
Address
Zipcode


we have a huge numbesr(millions) of such objects in the memory.Now i want to make a good design for the better memory utilization.
Means how and in what structure data should be kept to ensure effective memory utilizatio0n.We already have data structures like hashmap
,hashtable but beyond that can we use them or use other data structures in such a way that memory utilized by these objects is minimal.

design should be created keeping in mind that we can apply filters on any of the model attribute.(like from the structure if we want to see data of those
objects only where city name is newyork). So filtering done on the data should also be fast.

 
v Gupta
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have to keep the objects in memory?

The objects can be loaded from the database on need basis. An ORM tool like Hibernate can be used, it will also help in filtering the data as per the need.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12342
39
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think V Gupta is correct. The best way to improve your memory utilization is to not store so much stuff in memory.

Of course, there are tradeoffs, usually between speed, memory, and complexity of code. Software design is a constant push-pull between these three things. Personally, I find the last one to be the most important, most of the time. Keep your code simple and maintainable, and that will save you the most time and money in the end.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, the usage pattern for these objects makes a big difference.

For example if an object is used repeatedly when a "user" is in the system, a simple cache will prevent multiple trips to the DB.

On the other hand, if usage is random then caching would be extra effort. A google search for Java Cache will find lots and lots of entries.

Bill
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice posting Fred.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!