RFR: 8292989: Avoid dynamic memory in AsyncLogWriter

Xin Liu xliu at openjdk.org
Fri Sep 2 19:48:43 UTC 2022


On Fri, 2 Sep 2022 09:27:26 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> 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..).

okay. thanks. I will update this.

I prefer to detect this allocation failure and fall back to synchronous logging. This is for resource-constrained java. '-Xlog:async' shouldn't contribute a runtime error.

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

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


More information about the hotspot-runtime-dev mailing list