On Fri, 28 Jul 2023 19:59:15 GMT, Brian Burkhalter <b...@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.
>
> Brian Burkhalter has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   6478546: Move buffer clamping up to Java layer; correct read behavior to 
> match legacy

src/java.base/share/classes/java/io/FileInputStream.java line 257:

> 255:         try {
> 256:             do {
> 257:                 int size = Math.min(remaining, 1572864);

1.5Mb seems high, I think we really need micro that do real file I/O to help 
tune this.

src/java.base/share/classes/java/io/FileOutputStream.java line 347:

> 345:                 pos += n;
> 346:                 remaining -= n;
> 347:             } while (remaining > 0);

Long standing behavior is that write is a no-open with len is 0, meaning you 
can do while here (no need to change it to do-while). Same thing in RAF.

src/java.base/share/native/libjava/io_util.c line 160:

> 158:     }
> 159: 
> 160:     if (outOfBounds(env, off, len, bytes)) {

I assume the IS_NULL and outOfBounds checking in both readBytes and writeBytes 
are redundant now.

src/java.base/share/native/libjava/io_util.c line 183:

> 181:         if (fd == -1) {
> 182:             JNU_ThrowIOException(env, "Stream Closed");
> 183:             nwritten = -1;

nwritten is initialized to -1.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1278565903
PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1278565565
PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1278563940
PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1278564255

Reply via email to