memory usage of ArrayList<Integer>
arraylist, integer, java, memory-management
Solution
Try an integer list implementation that is optimized for memory usage, such as the one from the Colt library:
http://acs.lbl.gov/software/colt/api/cern/colt/list/IntArrayList.html
Java Integer objects usually require more overhead than an int primitive, so you need an implementation that is space-optimized.
From Colt:
Scientific and technical computing, as, for example, carried out at CERN, is characterized by demanding problem sizes and a need for high performance at reasonably small memory footprint. [...]
Problem
I’m using `ArrayList<Integer>` in my research project. I need to keep unknown number of integers in this list. Sometimes I need to update the list: remove existing records or add new records. As `Integer` is an object, it’s taking much more memory than only `int`. Is there any alternate way to maintain the list that will consume less memory than `Integer`?