-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible Memory Leak in StatusLogger’s ConcurrentLinkedQueue #3511
Comments
@ByteExceptionM, thanks so much for the report. If this doesn't fix your problem, would you mind providing the following details, please?
The size of |
Hi, @vy! As you can see in the screenshots I provided, the issue isn't limited to just the 200 StatusData instances. The memory usage is caused by an enormous amount of I understand that 2.23.1+ introduced major changes, but I can't simply upgrade to Log4j 2.24.3, because the Minecraft server (or one of its plugins) depends on Log4j 2.22.1. Unfortunately, I don't have a way to fully track which component is responsible for this dependency, so updating is difficult at the moment. As a workaround, I have now set the environment variable: The second screenshot shows how severe the issue became yesterday, with memory usage skyrocketing to 13.9 GB due to Thanks again for your help! |
Hey, @vy! I applied the workaround by setting: At first, it seemed to work fine. The server has been running for about 8 hours without any issues, and I didn't see any
The second screenshot I uploaded earlier shows how bad this issue got yesterday, reaching 13.9 GB of retained memory just from these objects. I'll keep monitoring the system, but any further ideas or suggestions would be greatly appreciated! Thanks again! |
Log4j follows semantic versioning, so you can safely upgrade to We only maintain the last minor version of each major branch, so there will never be a |
@ByteExceptionM, can you explain what do you exactly mean by applying this setting? Do you pass this as an environment variable to the associated Would it be possible to share a heap dump with us? If so, you can
1 You can encrypt it either using a password-protected ZIP, or via GPG. In the latter case, you need public keys of Log4j maintainers. |
My concern is not about compatibility, but about the practical feasibility of upgrading. In my environment, there are multiple software components relying on Log4j 2.22.1, including the Minecraft server itself and various plugins. The issue is that I do not have a clear way to track which components depend on this specific version, and I cannot simply replace or modify the software running my server without thorough testing and validation. This makes upgrading much more complex than just switching the Log4j version in a standalone application.
Yes, I applied the setting by passing it as an environment variable to the Java process: I can prepare a heap dump and will send it over soon. I'll follow the encryption and upload instructions and notify you via email when it's ready. Thanks again! |
Description
Log4j2's
StatusLogger$BoundedQueue
is causing a memory leak, where millions ofConcurrentLinkedQueue$Node
instances are being retained, leading to extreme memory usage.A heap dump analysis reveals:
ConcurrentLinkedQueue$Node
instances consuming 4.7 GB of RAM.ConcurrentLinkedQueue
instances consuming 2.4 GB of RAM.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
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 ofConcurrentLinkedQueue$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:
StatusLogger$BoundedQueue
will hold millions ofConcurrentLinkedQueue$Node
instances, consuming several gigabytes of RAM.I found that Log4j2 uses a
ConcurrentLinkedQueue
in theStatusLogger
implementation: StatusLogger.java, line 521This could be the reason for the uncontrolled memory growth, as the queue might not be properly cleared or bounded under certain conditions.
The text was updated successfully, but these errors were encountered: