0

Creating a matrix of size[15088][15088][5] in java runs me out of heap space using int as a datatype. How would I create one? Using the command -Xmx did not help.

int[][][] a=new int[15088][15088][5];
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373

1 Answers1

2

If you use 15088 * 15088 * 5 size of array, then the array needs 15088 * 15088 * 5 * 4 bytes = 4.24 GB(approximately)** of heap size. If the data is sparsely distributed then you could use other data structures like described in the following references.

Memory-efficient sparse array in Java

Community
  • 1
  • 1
Rishi
  • 1,163
  • 7
  • 12