Re: Unexepcted OutOfMemoryError from Arrays.deepToString

2021-10-09 Thread Andrey Turbanov
Created PR to remove AbstractStringBuilder.MAX_ARRAY_SIZE - https://github.com/openjdk/jdk/pull/5878 BTW, I found one more place where Integer.MAX_VALUE is used as maximum array length - java.util.concurrent.ScheduledThreadPoolExecutor.DelayedWorkQueue#grow I think this method could be reworked t

Re: Unexepcted OutOfMemoryError from Arrays.deepToString

2021-10-09 Thread Pavel Rappo
> On 9 Oct 2021, at 13:07, Pavel Rappo wrote: > > > > Separately, java.lang.AbstractStringBuilder#MAX_ARRAY_SIZE seems unused; I > wonder how that happened. I found what happened: $ git log -S "MAX_ARRAY_SIZE" -- src/java.base/share/classes/java/lang/AbstractStringBuilder.java commit 036

Re: Unexepcted OutOfMemoryError from Arrays.deepToString

2021-10-09 Thread Pavel Rappo
This error has two causes. The first cause is that the VM cannot allocate arrays whose length exceeds Integer.MAX_VALUE - 8 (MAX_ARRAY_SIZE). The second cause is that Arrays.deepToString tries to pre-allocate 20 chars per string representation for each array element and maxes out at Integer.MAX_