File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes ArrayList Size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList Size" Watch "ArrayList Size" New topic

ArrayList Size

narayana arya

Joined: Dec 12, 2005
Posts: 12
Does anybody knows ArrayList Maximum Size?
if i give ArrayList al=new ArrayList(Integer.MAX_VALUE);

then it is giving this exception:

java.lang.OutOfMemoryError: Requested array size exceeds VM limit
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Integer.MAX_VALUE is the maximum size of an ArrayList.
You are encountering an exhaustion of heap space (a failed alloc by the VM).
You can simply give your VM more heap space using the -Xmx option when you start it up

Tony Morris
Java Q&A (FAQ, Trivia)
I agree. Here's the link:
subject: ArrayList Size
It's not a secret anymore!