There is the following code in the onEvent() method:
But in case of an exception (or error) in the execute() method - method clear() will not be invoked, event will be not cleared (and logged message as well) and will be in the memory (probably try/catch will be enough to fix the issue).
I've faced this issue when OutOfMemoryError occurred due to very large messages logging (also message is duplication in the SimpleMessage class, please see related issue https://issues.apache.org/jira/browse/LOG4J2-2724) - all these event are still in memory and it causes a lot of another OOM errors as memory is not released (because clear() method was not invoked).
Please see attached RingBufferLogEvent_dominator_tree.txt report from Eclipse Memory Analyzer (https://www.eclipse.org/mat/). As you can see there are a log of RingBufferLogEvent object that were not cleared and garbage collected:
Also please see RingBufferLogEvent_OOM.log log file with OOM stacktrace:
Could you please fix it or explain if such behavior is expected?