[
https://issues.apache.org/jira/browse/CXF-8946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17777301#comment-17777301
]
Daniel Kulp commented on CXF-8946:
----------------------------------
Just adding some notes while investigating....
If the service client is properly closed, it goes forever. That's good news:
{code:java}
@Override
public String status() {
final StatusService service = JAXRSClientFactory.create(this.apiUrl,
StatusService.class,
Collections.singletonList(new GsonJsonProvider()));
try (AutoCloseable c = (AutoCloseable)service) {
final ClientConfiguration config = WebClient.getConfig(service);
final Slf4jVerboseEventSender slf4jVerboseEventSender = new
Slf4jVerboseEventSender();
config.getInInterceptors().add(new
LoggingInInterceptor(slf4jVerboseEventSender));
config.getOutInterceptors().add(new
LoggingOutInterceptor(slf4jVerboseEventSender));
return service.status();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
{code}
Also, if I update the sleep() method to add four calls to System.gc(), it also
runs forever. (three is not enough) Thus, the references ARE being released
eventually. It's just taking a lot longer that it should. Not sure why yet.
Still Investigating.
> HttpClient in CXF causing memory leak
> -------------------------------------
>
> Key: CXF-8946
> URL: https://issues.apache.org/jira/browse/CXF-8946
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 4.0.3
> Reporter: Sebastian Violet
> Priority: Major
> Attachments: CXF-HTTPClient-MemoryLeak.zip, java_pid17394.hprof.zip,
> java_pid17394_Leak_Suspects.zip, memory-leak-demo.zip
>
>
> When processing requests using the JAX RS client which used the new
> HttpClient, there is a memory leak.
> We found this when running it in spring boot using
> {code:java}
> @Async{code}
>
> I have tried to reproduce it using the attached code, and it seems to work
> with a low heap size.
>
> You can execute the code like so:
> {code:java}
> mvn compile exec:exec{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)