apache / apache/logging-log4j2
Memory Usage Increase in Log4j2 2.24.3 with Async Logging Due to RingBufferLogEvent
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.7k
- Avg merge
- 21h 30m
- Merged PRs (30d)
- 27
Description
## Description
I am using Log4j2 in my project and recently upgraded from version 2.23.1 to 2.24.3. The application employs an asynchronous logging strategy with Disruptor version 3.4.3. Below is the relevant configuration:
- `log4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector`
- `log4j2.asyncQueueFullPolicy=org.apache.logging.log4j.core.async.DiscardingAsyncQueueFullPolicy`
- `log4j2.discardThreshold=ERROR`
- `log4j2.asyncLoggerWaitStrategy=Yield`
- `log4j2.asyncLoggerRingBufferSize=1048576`
The logging frequency in my application is relatively low, averaging about 10 log entries per second. When using version 2.23.1, memory usage remained stable based on monitoring data . However, after upgrading to 2.24.3, I observed a gradual increase in memory usage over time, which eventually stabilizes at a fixed threshold.

This behavior differs significantly from what I experienced with 2.23.1. Through heap dump analysis at different time intervals, I confirmed that the memory growth is primarily associated with `RingBufferLogEvent` objects within Log4j2’s RingBuffer implementation, with the RingBuffer’s memory footprint consistently increasing over time.



I noticed that the 2.24.3 release includes several changes related to memory management. Could any of these changes, particularly those affecting the RingBuffer or `RingBufferLogEvent`, explain the behavior I am observing?
If additional details are needed, please let me know, and I’d be happy to provide them.
## Environment
- **Log4j2 Version**: 2.24.3 (upgraded from 2.23.1)
- **Disruptor Version**: 3.4.3
- **JVM**: Zing24.08.101.0+1 (build 21.0.4.0.101+1-LTS)
- **Logging Frequency**: ~10 logs/second
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.