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

オープン
#3,569 コメント 11 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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時間
マージ済み PR(30日)
24

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/logging-log4j2 のほかの issue

apache/logging-log4j2 の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。