-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Memory leak in non-quarkus main() in quarkus-using module (due to quarkus dependencies) #15220
Comments
I can confirm the leak. The problem is that I think that we should detect a non-quarkus main and skip the handler registration in that case. CC @dmlloyd @gsmet |
I believe @geoand looked into this (detecting a non-Quarkus main) a while ago and concluded that there isn't currently a really good mechanism for doing that? |
In that case, we could at least try to limit the size of the deque in the delayed handler? |
That is correct, I did three prototypes and none turned out to make any sense... |
To clarify the problem, the log configurator is installed independently of main (and likely before it ever starts) when the first log message is logged, with the intent of preventing log messages from being lost. The JDK gives no portable mechanism to determine what program was, or is about to be, started. The configurator has no access to this information, therefore it relies specifically on Putting a cap on the deque does not prevent the leak; it merely prevents the leak from crashing the program. We may need a pragmatic compromise, such as requiring the user to call a |
Sure it does not but if the limit is low enough (1000 records or so) the impact will be negligible for the user
That sounds reasonable but even if properly documented it's kind of unexpected. In other words, most users will never do that. Therefore, I believe that we should apply both the limit and the |
I suppose the error reporter could report a queue overrun in that case so the user would know of the problem. |
Do you mean BTW reporting an error does not really help in this particular case where dozens of log messages are written to the standard output... |
I think in this case, nothing will have been logged because the user main never set up the handler for it. So either they would get a one-time error saying they've overrun the queue and should configure logging correctly, or else they would get the logs that they want because they configured it correctly. |
Well, it is logged, maybe because the SLF4J adapter is used and the class that declares the main is using SLF4J API... |
That should only happen if there's some broken dependency (for example if they have included multiple SLF4J backend JARs). Trying to use other logging frameworks from a Quarkus project classpath will not ever work. |
I was able to reproduce the issue in three simple steps:
I don't see any other SLF4J backend in the dependency tree (only |
What exactly is being logged? |
Oh, I'm sorry. I got confused... |
To reproduce, take any quarkus quickstart and add this class in
src/test/java
(orsrc/main/java
):With JDK 11, I get this:
That takes a few minutes. Use
-Xmx64m
to get it in a few seconds.Its caused by jboss logging that by default remembers all logging statements in memory, see https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/Memory.20leak.2C.20logging.20and.20psvm
This memory leak might also affects unit tests that don't use quarkus integration.
Why is this a problem?
It's often useful to add plain old mains in a quarkus module too, without having to create yet another module for them. These do not replace the Quarkus main that is the actually application. Examples include:
All of these have alternative ways of accomplishing that goal, which are better but more work intensive: it's easier to temporary just add a plain-java main and it's very surprising that quarkus crippled that with a memory leak. It doesn't abide by the principle of least surprise.
The text was updated successfully, but these errors were encountered: