RFR: 8055949: ByteArrayOutputStream capacity should be maximal array size permitted by VM
Martin Buchholz
martinrb at google.com
Fri Aug 29 23:47:25 UTC 2014
I decided to care just enough about the last 2x of scalability, but not
about the last 8 elements.
Your code would resize the 2g elements 8 times before finally reaching
MAX_VALUE...
Now I'm back in not-caring-anymore mode.
At least about MAX_ARRAY_SIZE.
On Wed, Aug 27, 2014 at 3:41 AM, Ulf Zibis <Ulf.Zibis at cosoco.de> wrote:
> Am 25.08.2014 um 19:37 schrieb Martin Buchholz:
>
> https://bugs.openjdk.java.net/browse/JDK-8055949
>> http://cr.openjdk.java.net/~martin/webrevs/openjdk9/
>> ByteArrayOutputStream-MAX_ARRAY_SIZE/
>>
>> The 2x capacity gap was noticed by real users!
>>
>
> Hi Martin,
>
> the MAX_ARRAY_SIZE code now is copied to many places in JDK. Couldn't you
> better centralize the code to one place, e.g. j.u.Arrays or some hidden
> class of sun.java...?
> Isn't there a property to retrieve MAX_ARRAY_SIZE from the running VM?
>
> Imagine, some VM throws OOME above Integer.MAX_VALUE-4 and minCapacity is
> Integer.MAX_VALUE-4.
> With this code a OOME will happen:
> 124 return (minCapacity > MAX_ARRAY_SIZE) ?
> 125 Integer.MAX_VALUE :
> 126 MAX_ARRAY_SIZE;
> With this code we would avoid the OOME:
> 124 return (minCapacity > MAX_ARRAY_SIZE) ?
> 125 minCapacity :
> 126 MAX_ARRAY_SIZE;
>
> -Ulf
>
>
More information about the core-libs-dev
mailing list