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

Leo Wörteler commented on CXF-8885:
-----------------------------------

[~cachescrubber] That's a good catch! I've checked again with unclosed Clients, 
and there are indeed additional references to the {{HttpClientFacade}} that I 
missed. The {{ProxySelector}} is given an {{HTTPClientPolicy}} configuration 
object, and the property change listeners registered with that object hold 
references to the {{HttpClientHTTPConduit}}. That's incredibly hidden and 
subtle.

I've opened a [second PR|https://github.com/apache/cxf/pull/1380] in which I 
create a copy of the {{HTTPClientPolicy}} inside the {{ProxySelector}} that 
only contains relevant info and no listeners. That seems to do the trick (for 
now...).

My reproducing code can be found in [this 
gist|https://gist.github.com/LeoWoerteler/ecf7cc7d975990615a0a3b46152fa0b4]. 
Without the changes in my latest PR the number of threads stays constant:
{code:java}
200
200
200
1.023s {SelectorManager=3, Worker=7}
2.046s {SelectorManager=3, Worker=7}
3.063s {SelectorManager=3, Worker=7}
[...]
41.994s {SelectorManager=3, Worker=7}
[...]{code}
After the fix they die off quite quickly:
{code:java}
200
200
200
1.021s {SelectorManager=3, Worker=8}
2.049s {SelectorManager=3, Worker=8}
3.076s {} 
<terminated>{code}

> HttpClient SelectorManager threads run indefinitely causing OOM
> ---------------------------------------------------------------
>
>                 Key: CXF-8885
>                 URL: https://issues.apache.org/jira/browse/CXF-8885
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 4.0.0, 3.6.0
>            Reporter: Cardo Eggert
>            Priority: Major
>         Attachments: image (5).png
>
>
> Probably caused by https://issues.apache.org/jira/browse/CXF-8840 .
> Started to notice that when updating from 3.5.x to 3.6.0 that our servers 
> started getting OOM. Noticed from the resulting logs that a lot of threads 
> were active that were in the format 
> HttpClient-<NR>-SelectorManager
> when reverted to 3.5.6 then it did not occur anymore.
>  
> Tried to use VirtualVM when debugging it and saw when the thread was started, 
> it never died, basically meaning that it ran indefinitely. OOM happened when 
> there were about over 1000 of these threads.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to