I'm running a Tomcat web application in debug mode and, looking through the biggest objects with YourKit profiler, I see that by far the largest is a single instance of com.lmax.disruptor.RingBuffer
. I assume this has something with log4j, which uses RingBuffer
internally to report asynchronously. Is there any way I can reduce the memory footprint of this object? Why is it so large?
From Async Log4j2, memory leak?:
The implementation of Apache Log4j2 in async mode uses a RingBuffer to buffering all the logs content. By default uses 262144 slots (256 * 1024). This causes an initial memory reserve of approximately 40 megabytes and in a environment with a limited memory causes the memory head to be always full and therefore the starting slowdown.
To reduce the memory usage, reduce the RingBuffer size (number of slots) by setting the system property:
log4j2.asyncLoggerRingBufferSize=value
The minimum size is 128. To allocate 5Mb set the value to 32768. See Log4j Async Loggers for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With