RFR: 8292989: Avoid dynamic memory in AsyncLogWriter

Thomas Stuefe stuefe at openjdk.org
Fri Sep 2 09:29:39 UTC 2022


On Wed, 31 Aug 2022 18:12:09 GMT, Johan Sjölén <duke at openjdk.org> wrote:

>> I have no idea how to handle the error that malloc returns NULL in ctor. Maybe I am paranoid. glibc/malloc rarely fails because it maps but not commit a memory segment.  We also define the constraint of AsyncLogBufferSize in globals.hpp.
>
> You're right, I forgot how impossible that case is.  Being paranoid with this is fine, imho.

Probably extremely rare, since argument parsing needs C-heap too, for malloc=NULL to hit right here. Not impossible though (limits, sbrk exhausted, etc). Note that we have other libcs too.

But I agree with @jdksjolen original remark. Buffer managing its memory would be more straightforward. No need to handle malloc errors if you just use NEW_C_HEAP_ARRAY and let it fatal out in case of an OOM. Its what we do all over hotspot. Would also save you the ugly cast (why do C++ casts have to be so verbose..).

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

PR: https://git.openjdk.org/jdk/pull/10092


More information about the hotspot-runtime-dev mailing list