Memory Usage Increase in Log4j2 2.24.3 with Async Logging Due to RingBufferLogEvent

未关闭
#3,569 11 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
java

调研方向

从 Log4j2 2.23.1 到 2.24.3 之间引入的 RingBufferLogEvent 和 RingBuffer 内存管理变更入手,并使用提供的异步日志配置作为复现上下文。比较两个版本中的堆行为,并确定报告的增长是预期现象还是回归;完成的标准是记录原因和可复现的结果。

由索引模型根据 Issue 内容生成。

描述

async performance question waiting-for-maintainer

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.
Figure 1

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.

Image

Image

Image

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
主要语言
Java
星标
3.6k
派生
1.8k
平均合并
5 天 6 小时
30 天内合并 PR
24

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/logging-log4j2 的其他 Issue

查看 apache/logging-log4j2 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。