RFR: 6478546: FileInputStream.read() throws OutOfMemoryError when there is plenty available
Brian Burkhalter
bpb at openjdk.org
Fri Jul 21 22:46:54 UTC 2023
On Fri, 21 Jul 2023 22:40:00 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Limit native memory allocation and move write loop from the native layer into Java. This change should make the OOME reported in the issue much less likely.
The cost of native memory allocation appears to degrade the throughput of reads and writes of larger arrays. Above a certain size, allocating and looping over a smaller array was measured to achieve higher throughput.
As `Objects::checkFromIndexSize` now guards against out of bounds conditions, and obtaining the array length as its third parameter provides a null check, the NULL and bounds checks could be removed from the C code.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14981#issuecomment-1646312987
More information about the security-dev
mailing list