-
Notifications
You must be signed in to change notification settings - Fork 357
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 when using Jersey with HK2 #5796
Comments
Hi @jbescos, look at class |
One note, in your example you have:
That cannot release the clients, because it is inside the try block (
|
After modifying your example, I don't find |
If you consider a long running application, where a |
Right, but I am not sure this is designed in that way. From what I see, ClientRuntime is created for each request and in can be released in 2 ways: However, the point 2 is not good to happen because Maybe I am wrong, but it looks it is an issue in the design. ClientRuntime should be discarded from memory after every request, and it should not have any onClose action. Connections should be released after |
It seems this was introduced here: #4508 If I revert it, there are 0 instances of ClientRuntime |
This looks like a bug in Jersey. Removing HK2 by adding
leaves the 100 ClientRuntimes as well. |
It is this: jersey/core-client/src/main/java/org/glassfish/jersey/client/ClientMessageBodyFactory.java Line 62 in 382f69e
There are also 100 instances of ClientMessageBodyFactory.MessageBodyWorkersConfigurator`. The problem is that if we remove that, we will have again this issue #4507 I think the proper fix is that Probably it is easier fix is to keep the reference to |
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
The reproducer contains:
Interestingly, with the |
When using Jersey and Jackson to deserialize XML, any change to the configuration of the WebTarget causes a memory leak since hk2 3.0.4 (and up to 3.1.1).
I suspect this is caused by this change in HK2: eclipse-ee4j/glassfish-hk2@9e5b5f5 (FISH-6432 Applications Take Longer To Deploy on JDK 17) since the same occurs with the patched Payara version 3.0.1.payara-p2 (payara/patched-src-hk2@3.0.1.payara-p1...3.0.1.payara-p2).
Not sure if this is a regression in HK2 or something that Jersey is doing incorrectly.
I've tested with Jersey version 3.0.0 to 3.1.9, and the behavior is the same.
See the attached example project.
jersey-memory-leak.zip
Also posted on HK2: eclipse-ee4j/glassfish-hk2#1126
The text was updated successfully, but these errors were encountered: