RFR: 8292989: Avoid dynamic memory in AsyncLogWriter

Johan Sjölén duke at openjdk.org
Wed Aug 31 18:14:22 UTC 2022


On Wed, 31 Aug 2022 18:06:26 GMT, Xin Liu <xliu at openjdk.org> wrote:

>> src/hotspot/share/logging/logAsyncWriter.cpp line 125:
>> 
>>> 123:   size_t size = align_up(AsyncLogBufferSize / 2, page_size);
>>> 124: 
>>> 125:   char* buf0 = static_cast<char* >(os::malloc(size, mtLogging));
>> 
>> Is there a particular reason that AsyncLogWriter allocates and handles the resources intended for `Buffer` instead of `Buffer` doing it itself in its ctr and dtr?
>
> 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.

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

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


More information about the hotspot-runtime-dev mailing list