-1

For one of the use case I wanted to store approx 900,000 customer number to do shuffling. It will have 2 columns - one original customer num and the other shuffled customer num.

What is the best approach using Java, so that I don't get memory exception or GC overhead?

Thanks.

Aavik
  • 967
  • 19
  • 48
  • 1
    900,000 numbers would be less than 10Mb, I think you'll be just fine as long as you're not running on a GameBoy. – AntoineB Oct 23 '18 at 08:18
  • Seriously, this is hardly something related to collections. If your data is going to exceed heap size, using *any* collection or data structure is going to give you the same thing... unless you are looking for special API that does compression and stuff like that. – Jai Oct 23 '18 at 08:22

1 Answers1

0

It is not much to store 900k numbers if a number is only 4 bytes. If you exceed the heap you can also increase the heap size with Increase heap size in Java.

If your data grows and you need much space, then you can use a off the heap datastructure like http://www.mapdb.org/. They provide an Implementation of the List or Set or Map interface but save some data to the disk instead of the heap.

Charlie
  • 1,169
  • 2
  • 16
  • 31