You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "GIRISH KULKARNI (JIRA)" <ji...@apache.org> on 2018/01/17 17:17:00 UTC

[jira] [Commented] (HTTPCLIENT-1749) Memory Leak in OSGi support

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16329035#comment-16329035 ] 

GIRISH KULKARNI commented on HTTPCLIENT-1749:
---------------------------------------------

It does not look like the leak is fixed. While HttpClient instances are now freed because of the weak references, the trackedHttpClients collection itself continues to hold the java.lang.ref.WeakReference objects for ever. It appears that the purpose of the checkReferences method is to remove these objects, but it never gets called. The test calls the size() method which removes the null references, but there is no way to call the size() or the checkReferences() method otherwise.

!image-2018-01-17-09-16-20-350.png!

> Memory Leak in OSGi support
> ---------------------------
>
>                 Key: HTTPCLIENT-1749
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1749
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 4.4.1, 4.5.2
>            Reporter: Justin Edelson
>            Priority: Major
>             Fix For: 4.5.3
>
>         Attachments: HTTPCLIENT-1749-2.diff, HTTPCLIENT-1749.patch, image-2018-01-17-09-16-20-350.png
>
>
> There is a memory leak in the HTTP Client OSGi support whereby the HttpProxyConfigurationActivator holds on to references to created HttpClient instances for the entire life of the httpclient-osgi bundle, which may be (and probably is in many cases) longer than the lifespan of individual HttpClient instances.
> The clients are added here: http://grepcode.com/file/repo1.maven.org/maven2/org.apache.httpcomponents/httpclient-osgi/4.4.1/org/apache/http/osgi/impl/OSGiHttpClientBuilder.java#58
> and not removed until http://grepcode.com/file/repo1.maven.org/maven2/org.apache.httpcomponents/httpclient-osgi/4.4.1/org/apache/http/osgi/impl/HttpProxyConfigurationActivator.java#115
> This can be relatively easily fixed by using weak references. In addition, access to this collection needs to be synchronized because the additions may come from multiple threads.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org