RFR: 8316156: (ch) Channels.newOutputStream(ch).write(bigByteArray) allocates a lot of direct memory [v4]
Alan Bateman
alanb at openjdk.org
Fri Sep 15 06:41:39 UTC 2023
On Thu, 14 Sep 2023 22:51:10 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> In `ChannelInputStream` and `ChannelOutputStream`, process small chunks of bytes in sequence to avoid running afoul of the `MaxDirectMemorySize`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8316156: Read at most DEFAULT_BUFFER_SIZE bytes
src/java.base/share/classes/sun/nio/ch/ChannelInputStream.java line 71:
> 69: return 0;
> 70:
> 71: bb.limit(pos + Integer.min(rem, Streams.DEFAULT_BUFFER_SIZE));
I assume we would end up with a MAX_BUFFER_SIZE that is something like 128k, like we ended up in NioSocketImpl for the same reason. In order words, it's different to the chunk size that is DEFAULT_BUFFER_SIZE today.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15733#discussion_r1326863659
More information about the nio-dev
mailing list