Reputation: 23
This line of code creates an error message "Memory limit exceeded" when length is 100,000 and I don't quite understand why.
int[][] multiply = new int[length][length];
Upvotes: 1
Views: 413
Reputation: 26703
You try to make an array of 100,000 * 100,000 entries of probably 4 bytes each.
That is 40,000,000,000 bytes, around 40GB. Even if you have that kind of memory installed, the system will probably enforce some limits long before that.
Upvotes: 10