i have a large list of static data from a server that i load on startup. I load this into a hashtable of foo objects. the user has a dropdown where they can choose one of these object. by default there are 50,000 objects which take up a lot of memory. i am trying to reduce memory
after monitoring usage, it turns out that most people only use about 1,000 of them. i want to have it so the gui only loads up those 1000 and if they need to select one that is outside that 1000 then they can go back to the server or to disk.
what would be the best way of doing this . .
Depending on the nature of your data how about forgetting about the whole thing and leave it up to the OS? Put it in a memory-mapped file.
I'm assuming you're filtering this list elsewhere...otherwise that's quite a list. The easiest way to hit your new, leaner static cache before hitting the DB will be to pass all requests through a single method:
The problem with loading a 1000 first is
Who would scroll a 1000?
The going back to the disk will cause the dropdown to reset and they'll have to scroll again.
Solution
Why not implement a auto search dropdown, and try caching app block, it works great for me with extensive amounts of data.
Look at devexpress dropdown edit, you'll need to purchase their controls though.
50,000 objects seems a bit excessive for a dropdown menu item. Maybe you want to look at an alternative widget, like a table with paging...
You have a dropdown with 50000 items in it? That seems a trifle excessive. Perhaps a list view control? Also you can create the listview as a Virtual list view - in this mode it will only load the items as needed, the other items can be loaded if they would be scrolled into view. Since you are having so many items in the list view, I suggest you work on some kind of search control that the user can use to narrow down the list of items.