V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
varnotfound
V2EX  ›  Java

ArrayList 的最大长度为什么是 int 最大值减 8,不懂这 8 个长度去做什么了

  •  
  •   varnotfound · Sep 17, 2015 · 4251 views
    This topic created in 3875 days ago, the information mentioned may be changed or developed.

    ArrayList 使用数组来存储数据,数组的下标为 int 型。在 ArrayList 的源码中定义的存储数组下标最大值为:

    private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;

    不明白这减个 8 是用来存储什么的?注释” Some VMs reserve some header words in an array “ 没懂这指的是什么? jvm 原理中也没有找到数组存储的最大容量的显式说明,请各位技术大神解惑 :-)
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6049 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 03:06 · PVG 11:06 · LAX 20:06 · JFK 23:06
    ♥ Do have faith in what you're doing.