RFR: 8316156: (ch) Channels.newOutputStream(ch).write(bigByteArray) allocates a lot of direct memory

Bernd duke at openjdk.org
Thu Sep 14 04:24:37 UTC 2023


On Thu, 14 Sep 2023 03:05:50 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`.

src/java.base/share/classes/sun/nio/ch/ChannelInputStream.java line 73:

> 71:         int rem = bb.limit() - pos;
> 72:         while (rem > 0) {
> 73:             int size = Integer.min(rem, DEFAULT_BUFFER_SIZE);

Should this limit in the read case not apply for direct buffers? (I.e. they are allocated already?). Also should it really use „DeFAULT_“ maybe more like a CHUnK_LIMIT more around 128k?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15733#discussion_r1325336015


More information about the nio-dev mailing list