HashMap alternatives for memory-efficient data storage

前端 未结 10 1446
逝去的感伤
逝去的感伤 2020-12-24 06:50

I\'ve currently got a spreadsheet type program that keeps its data in an ArrayList of HashMaps. You\'ll no doubt be shocked when I tell you that this hasn\'t proven ideal.

10条回答
  •  误落风尘
    2020-12-24 07:35

    Why don't you try using cache implementation like EHCache. This turned out to be very effective for me, when I hit the same situation.
    You can simply store your collection within the EHcache implementation. There are configurations like:

    Maximum bytes to be used from Local heap.
    

    Once the bytes used by your application overflows that configured in the cache, then cache implementation takes care of writing the data to the disk. Also you can configure the amount of time after which the objects are written to disk using Least Recent Used algorithm. You can be sure of avoiding any out of memory errors, using this types of cache implementations. It only increases the IO operations of your application by a small degree.
    This is just a birds eye view of the configuration. There are a lot of configurations to optimize your requirements.

提交回复
热议问题