您的位置:首页 > 编程语言 > Java开发

Java数组长度最大能有多大?

2016-09-23 15:22 369 查看
down
vote
This is (of course) totally VM-dependent.

Browsing through the source code of OpenJDK 7 and 8 
java.util.ArrayList
.Hashtable
.AbstractCollection
.PriorityQueue
,
and 
.Vector
,
the eight is size of header words.,you can see this claim being repeated:

/**
* Some VMs reserve some header words in an array.
* Attempts to allocate larger arrays may result in
* OutOfMemoryError: Requested array size exceeds VM limit
*/
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;


down
vote
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: