RFR: 8316156: (ch) Channels.newOutputStream(ch).write(bigByteArray) allocates a lot of direct memory
Alan Bateman
alanb at openjdk.org
Thu Sep 14 06:48:35 UTC 2023
On Thu, 14 Sep 2023 04:22:03 GMT, Bernd <duke at openjdk.org> wrote:
> 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?
There is an argument that the channels (the implementations SocketChannel, FileChannel, ...) should clamp the size when called with a ByteBuffer that is backed by a byte[]. I think we have to be cautious about changing things at that level as it would have much wider impact. It also gets more complicated with scatter/gather ops.
So clamping in the input stream/output streams as done in the COS.write change is okay.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15733#discussion_r1325427962
More information about the nio-dev
mailing list