Why the maximum array size of ArrayList is Integer.MAX_VALUE - 8?
<p>I am studying Java 8 documentation for <code>ArrayList</code>. I got that maximum array size is defined as <code>Integer.MAX_VALUE - 8</code> means 2^31 – 8 = <strong>2 147 483 639</strong>. Then I have focused on why 8 is subtracted or <code>why not less than 8</code> or <code>more than 8</code> is subtracted?</p>

<pre><code>/**
 * The maximum size of array to allocate.
 * 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;
</code></pre>

<p>I got some related answers but not fulfilling my thrust.</p>

<ol>
<li><a href="https://stackoverflow.com/questions/3038392/do-java-arrays-have-a-maximum-size">Do Java arrays have a maximum size?</a></li>
<li><a href="https://stackoverflow.com/questions/3767979/how-many-data-a-list-can-hold-at-the-maximum">How many data a list can hold at the maximum</a></li>
<li><a href="https://stackoverflow.com/questions/31382531/why-i-cant-create-an-array-with-large-size">Why I can't create an array with large size?</a></li>
</ol>

<p>Some people given some logic that as per documentation <code>"Some VMs reserve some header words in an array"</code>. So for header words, 8 is subtracted. But on that case, if header words need more than 8, then what will be the answer?</p>

<p>Please clarify me on that basis. Advance thanks for your cooperation.</p>