According to this site, memory usage for arrays is a 12-byte header + 4 bytes per element. If you declare an empty Object array containing 10M elements, then you have approximately 40 MB of memory used from the very beginning. If you start filling this array with a 10M object, the size increases quite quickly.
From this site, and I just tested it on my 64-bit machine, the size of a simple Object is about 31 bytes, so an array of 10M Object is about 12 bytes + (4 + 31 bytes) * 10M = 350,000 012 bytes (or 345 , 78 MB)
If your array contains objects of a different type, the size will be even larger.
I would advise you to use some kind of random access file to store data if you need to store so much data inside your program. Or even use a database like Apache Derby , which will also allow you to sort and filter your data, etc.
source share