On Fri, 27 Jun 2025 23:00:04 GMT, Brian Burkhalter <b...@openjdk.org> wrote:
>> src/java.base/share/classes/java/io/Reader.java line 504: >> >>> 502: } >>> 503: if (fragLen >= cb.length/2) { >>> 504: // allocate larger buffer and copy chars to >>> beginning >> >> It might be designed to use a more conservative resizing approach, for >> example, **cb.length + TRANSFER_BUFFER_SIZE**, rather than exponential >> doubling, more in line with how resizing is handled in string builder. not >> a very strong opinion though :-) > >> [...] more in line with how resizing is handled in string builder > > Looks like `StringBuilder` eventually calls > `ArraysSupport.newLength(int,int.int)`. This is probably worth checking out. On the call to ArraysSupport.newLength(curr, min, preferred). This will double the size (preferred) until it runs past SOFT_MAX_ARRAY_LENGTH. Then it starts growing by minGrowth, it should probably be smaller; something that will allow it to get pretty close to SOFT_MAX_ARRAY_LENGTH before throwing OOME. But still large enough to allow efficient reads. Maybe 4k, or 8k, or 16k. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25863#discussion_r2180106662