ByteExceptionM opened a new issue, #3511:
URL: https://github.com/apache/logging-log4j2/issues/3511

   ## Description
   
   Log4j2's `StatusLogger$BoundedQueue` is causing a **memory leak**, where 
millions of `ConcurrentLinkedQueue$Node` instances are being retained, leading 
to extreme memory usage.
   
   A heap dump analysis reveals:
   
   -   **210,815,632** `ConcurrentLinkedQueue$Node` instances consuming **4.7 
GB** of RAM.
   -   **105,409,426** `ConcurrentLinkedQueue` instances consuming **2.4 GB** 
of RAM.
   
   
![Image](https://github.com/user-attachments/assets/750d002b-6e7c-4932-81e7-22653b14f93f)
   
![Image](https://github.com/user-attachments/assets/fbf75b00-d925-4d78-bcdc-d749244ba70d)
   
![Image](https://github.com/user-attachments/assets/c242fe09-0013-471f-be7c-ddb5a546b10e)
   
   This issue occurs on a **single node** running Log4j **2.22.1**, and has 
only started happening recently, without any noticeable log warnings or errors.
   
   ## Configuration
   
   -   **Version:** Log4j 2.22.1
   -   **Operating system:** Private Docker image, based on 
**itzg/minecraft-server**
   -   **JDK:** JDK 21.0.6+7
   -   **Container environment:** Running within a Docker container
   
   ## Logs
   
   There are no noticeable errors or stack traces. The issue was identified 
through heap dump analysis, which shows that `StatusLogger$BoundedQueue` is 
retaining a massive number of `ConcurrentLinkedQueue$Node` instances, leading 
to a memory leak of over **4.9 GB**.
   
   ## Reproduction
   
   The exact trigger is unknown, but the issue was observed on a **high-load 
Minecraft server** using Log4j **2.22.1**. To reproduce:
   
   1.  Start a Minecraft server using Log4j 2.22.1.
   2.  Run the server under normal operational load (many background log 
events).
   3.  Leave it running for several hours or days.
   4.  Generate a heap dump and analyze memory usage.
   5.  If affected, `StatusLogger$BoundedQueue` will hold millions of 
`ConcurrentLinkedQueue$Node` instances, consuming several gigabytes of RAM.
   
   I found that Log4j2 uses a `ConcurrentLinkedQueue` in the `StatusLogger` 
implementation: [StatusLogger.java, line 
521](https://github.com/apache/logging-log4j2/blob/8d05a73372a8f5fcc9df5f3c12413179174e7fb5/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusLogger.java#L521)
   
   This could be the reason for the uncontrolled memory growth, as the queue 
might not be properly cleared or bounded under certain conditions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to