Integrated: 8316156: ByteArrayInputStream.transferTo causes MaxDirectMemorySize overflow
Brian Burkhalter
bpb at openjdk.org
Wed Sep 20 20:45:53 UTC 2023
On Thu, 14 Sep 2023 03:05:50 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> `ByteArrayInputStream.transferTo` invoked with an `OutputStream` parameter which delegates to a `FileChannel` throws an `OutOfMemoryError` if the length of the `byte[]` wrapped by the `ByteArrayInputStream` exceeds `MaxDirectMemorySize`. This is because `FileChannel.write` uses `IOUtil.write` which creates a temporary direct buffer for writing. If the `byte[]` length is larger than `MaxDirectMemorySize`, then the temporary direct buffer allocation fails with an `OutOfMemoryError`.
This pull request has now been integrated.
Changeset: 5cacf212
Author: Brian Burkhalter <bpb at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/5cacf212f066f5694d01f0891adfbe8b38660175
Stats: 83 lines in 2 files changed: 81 ins; 0 del; 2 mod
8316156: ByteArrayInputStream.transferTo causes MaxDirectMemorySize overflow
Reviewed-by: alanb
-------------
PR: https://git.openjdk.org/jdk/pull/15733
More information about the nio-dev
mailing list