Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Array size limitations

807588May 6 2009 — edited May 7 2009
Does Java impose some form of array length limitations that doesn't involve INT_MAX or memory size of allocation?

I have a perplexing error surrounding VM memory limits. Machine is 64 bit x86 with 64GB of RAM. I have increased heap space to 64GB and application only reaches ~15GB, but can increase to 20-30GB without any problems.

Specifically, the error is of type:

java.lang.OutOfMemoryError: Requested array size exceeds VM limit

But I have plenty of heap space. To prove this, I wrote the following code (and the error shows the appropriate line is triggering the error)
int[] x = null;
x = new int[600000000];  // triggers error
int[] x = null;
int[] a = null;
int[] b = null;
int[] c = null;
a = new int[500000000];
b = new int[500000000];
c = new int[500000000];
x = new int[600000000]; // triggers error
So the 3 arrays a,b,c take up much more memory than x. However, x triggers the error in both circumstances.

Thanks for any insight you have into the problem!

Aaron

Edited by: aaron101net on May 6, 2009 8:23 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 4 2009
Added on May 6 2009
25 comments
2,231 views