I'm trying to memory-optimize my server that keeps running into OOM.
Most of the objects (by count) in the server take the following form:
- Each object is a HashMap
- HashMap keys are strings
- HashMap values are objects of Attribute class, which just has an int and 2 booleans.
Important caveat: 95% of such hashmaps would ONLY EVER have one key; and I know whether that's the case when creating the hashmap.
There are millions of these hashmaps.
I already asked a separate question about optimizing those hashmaps memory wise, and someone in a comment suggested that perhaps re-engineering my whole data structure would be better since even with initial size of "1" HashMaps still take up extra memory.
As such, my question is; is there a better Java data structure I can implement which can store the same exact data with better memory efficiency?
NOTE: I need to be able to look up whether a specific value is present as a key; therefore I have considered but rejected storing the data in an list of quintuples of [string_value, int, boolean, boolean].