0

So, I have:

LinkedHashMap <String, LinkedHashMap <String , ArrayList<Integer>>> MYMap = new LinkedHashMap <String, LinkedHashMap <String , ArrayList<Integer>>>

Each Key in the hashmap the size of the ArrayList will increase by one, and it starts at one. So When I reach key 176 it will have 176 integers in the ArrayList. So Obviously I get out of memory. Now I DO NEED to have ALL of those integers in the array. What are my options. AND if it's increasing the heap size, I need a way that when I do hand this project to someone they do not have to know that they have to increase the size.

dsuma
  • 1,000
  • 2
  • 9
  • 30
  • possible duplicate of [Setting JVM heap size at runtime](http://stackoverflow.com/questions/763295/setting-jvm-heap-size-at-runtime) – rath Apr 28 '14 at 06:41
  • This answer should also help http://stackoverflow.com/questions/17204757/in-java-is-it-possible-to-increase-the-jvms-available-memory-and-or-kill-other/17204785#17204785 – AurA Apr 28 '14 at 06:42
  • 2
    Alternatively you could try less memory-hungry algorithm – rath Apr 28 '14 at 06:42
  • No idea what you want to do but you should consider using Guava's `Table` -- or build better classes – fge Apr 28 '14 at 06:44
  • 1
    It sounds like a choice of algorithm issue. You can increase the heap, but you'll be getting diminishing returns as you need it to get bigger and bigger. You might be able to use a more efficient structure, or you might be able to stream the data, processing smaller pieces independently. Nobody can help there unless you explain the situation. – Dave Apr 28 '14 at 06:59
  • Have you looked at BitSet, this uses 1 bit per value instead of the 32-bits per Integer reference in the ArrayList. If you are adding Integers to the list why are you using String for the key? – Peter Lawrey Apr 28 '14 at 07:33

0 Answers0