[
https://issues.apache.org/jira/browse/HTTPCLIENT-2424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18086698#comment-18086698
]
Oleg Kalnichevski commented on HTTPCLIENT-2424:
-----------------------------------------------
[~rjampani]
> A new client is created for every request and off course within in try with
> resources, which ensures the resources are closed.
This is a bad practice, very inefficient and strongly discouraged. One should
re-use the same instance of HttpClient as much as possible. During periods of
inactivity one may evict persistent connections from the connection pool
instead of closing the pool and the client
> Could you please confirm if this is candidate for potential memory leak ?
No, I cannot. You need to provide specific details as to what class of objects
gets leaked or, better yet, provide a locally executable reproducer.
> The version 4.5.14.
More importantly, we no longer provide any support for the 4.5.x code line
beyond major security issues. Please consider upgrading to HttpClient 5.6.
Oleg
> Http Client leaking memory
> --------------------------
>
> Key: HTTPCLIENT-2424
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2424
> Project: HttpComponents HttpClient
> Issue Type: Test
> Components: HttpClient (classic)
> Affects Versions: 4.5.14
> Environment: java 17
> Reporter: Ravisankar Jampani
> Priority: Major
>
> We have this piece of code,
> 1. Make http "GET" and receive the response from another service
> 2. A new client is created for every request and off course within in try
> with resources, which ensures the resources are closed.
> 3) We are observing a memory leak after a very long run.
> Could you please confirm if this is candidate for potential memory leak ?
> The version 4.5.14.
> {code:java}
> public String processActionSummaryRequest(String URIPath) {
> HttpGet request = new HttpGet(URIPath);
> String result = null;
> RequestConfig config = RequestConfig.custom()
> .setConnectTimeout(controlActionGetApiTimeout * 1000)
> .setConnectionRequestTimeout(controlActionGetApiTimeout * 1000)
> .setSocketTimeout(controlActionGetApiTimeout * 1000)
> .build();
> try (CloseableHttpClient httpClient = HttpClients.custom()
> .setDefaultRequestConfig(config)
> .build();
> CloseableHttpResponse httpResponse = httpClient.execute(request)) {
> HttpEntity entity = httpResponse.getEntity();
> if (entity != null) {
> result = EntityUtils.toString(entity);
> }
> } catch (IOException e) {
> throw new EndpointManagementGetControlSignalRetrievalException(
> e.getMessage());
> }
> return result;
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]