On Mon, 24 Jul 2023 13:16:56 GMT, Alan Bateman <al...@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.
>
> src/java.base/share/native/libjava/io_util.c line 62:
> 
>> 60: /* The maximum size of a dynamically-allocated buffer.
>> 61:  */
>> 62: #define MAX_MALLOC_SIZE 2097152
> 
> How did you choose 2Mb, it seems high.

It's based on micro-benchmarks. Having the loops in Java reduces throughput but 
allocating memory using `malloc(len)` also reduces throughput as `len` gets 
larger and this threshold appears to balance the two.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1272921060

Reply via email to