RFR: 8316156: (ch) Channels.newOutputStream(ch).write(bigByteArray) allocates a lot of direct memory [v2]
Brian Burkhalter
bpb at openjdk.org
Thu Sep 14 15:57:41 UTC 2023
On Thu, 14 Sep 2023 06:28:22 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8316156: Address reviewer comments
>
> src/java.base/share/classes/sun/nio/ch/ChannelInputStream.java line 49:
>
>> 47: */
>> 48: class ChannelInputStream extends InputStream {
>> 49: static final int DEFAULT_BUFFER_SIZE = 8192;
>
> I don't think COS should be using CIS.DEFAULT_BUFFER_SIZE, maybe it should be moved to Streams which is the factory class for the streams based on channels.
Moved to `Streams` in a9af89cff869c441c6dd04f635a4d93e7757f2fa.
> src/java.base/share/classes/sun/nio/ch/ChannelInputStream.java line 68:
>
>> 66: * If the channel is selectable then it must be configured blocking.
>> 67: */
>> 68: private int readFully(ByteBuffer bb) throws IOException {
>
> InputStream.read methods are not "read fully", it will cause the read to hang, say where you read some bytes and block indefinitely to fill the user's buffer.
I was ambivalent about that name as well. Changed in a9af89cff869c441c6dd04f635a4d93e7757f2fa.
> test/jdk/java/nio/channels/Channels/WriteFullyMemorySize.java line 54:
>
>> 52: throw new RuntimeException("Arrays are not equal");
>> 53: } finally {
>> 54: Files.delete(target);
>
> The test is for CIS.read/COS.write so I guess it should directly exercise those methods.
So changed in a9af89cff869c441c6dd04f635a4d93e7757f2fa.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15733#discussion_r1326165608
PR Review Comment: https://git.openjdk.org/jdk/pull/15733#discussion_r1326166354
PR Review Comment: https://git.openjdk.org/jdk/pull/15733#discussion_r1326167019
More information about the nio-dev
mailing list