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];
2
  • can't you use any other data type? like bitset, etc. Commented Mar 20, 2016 at 2:43
  • 1
    @nithin kumar this is very big array it requires more than 4gb ram. Commented Mar 20, 2016 at 2:52

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

You to use OpenIntObjectHashMap from Colt library, which needs significantly lower memory, when compared to other alternatives.
How do you create an arrays of array using list or hash set ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.