Files.copy(InputStream, Path, CopyOption...) can fail with OOM if direct memory is limited
github at paul.kungfoocoder.org
github at paul.kungfoocoder.org
Tue Sep 12 21:39:20 UTC 2023
Hi Alan,
> On 12 Sep 2023, at 20:58, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>
> On 12/09/2023 18:05, github at paul.kungfoocoder.org <mailto:github at paul.kungfoocoder.org> wrote:
>> Note that this isn't strictly a problem of Files.copy, but rather of the output stream returned byFiles.newOutputStream, as evidenced by echo 'new java.io.ByteArrayInputStream(new byte[256*1024*1024]).transferTo(java.nio.file.Files.newOutputStream(java.nio.file.Path.of("/tmp/aaa")));' | jshell -R-XX:MaxDirectMemorySize=25M
>>
> Right, it's ChannelOutputStream.writeFully that doesn't limit the size of the writes to the underlying FileChannel. Improving that would reduce direct buffer usage for several operations (not just copy).
Agreed. My question is what is the next step now that I have identified this problem? Do others agree that this is something that should be fixed? What can I do to move this forward?
Cheers,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/nio-dev/attachments/20230912/bca00321/attachment.htm>
More information about the nio-dev
mailing list