Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8902

Resource Leak at HttpClientHTTPConduit leads to OutOfMemoryError

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 4.0.2
    • None
    • Services
    • None
    • Unknown

    Description

      Hello,

      I use the BingAds SDK. This SDK uses CXF to communicate with the Bing servers. After they upgraded CXF from 3.4.2 to 4.0.2 I run into OutOfMemoryErrors that actually are OutOfThreadsErrors:
      java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached

      The reason for the error is, that HttpClientHTTPConduit sets up a HttpClientImpl for each service call:

      	at jdk.internal.net.http.HttpClientImpl$SelectorManager.<init>(HttpClientImpl.java:715)
      	at jdk.internal.net.http.HttpClientImpl.<init>(HttpClientImpl.java:325)
      	at jdk.internal.net.http.HttpClientImpl.create(HttpClientImpl.java:270)
      	at jdk.internal.net.http.HttpClientBuilderImpl.build(HttpClientBuilderImpl.java:135)
      	at org.apache.cxf.transport.http.HttpClientHTTPConduit.setupConnection(HttpClientHTTPConduit.java:231)
      	at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:529)
      	at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:47)
      	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
      	at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:528)
      	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:439)
      	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:354)
      	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:312)
      	at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
      	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140)
      	at jdk.proxy2.$Proxy100.getAccount(Unknown Source:-1)
      

      Each time a HttpClientImpl is build, a HttpClientImpl$SelectorManager thread is created. in my case this led to more than 6000 threads and in the end to the OutOfMemoryError.

      Could you please either return URLConnectionHTTPConduit by default in HTTPTransportFactory#getConduit or try to re-use the HttpClient or shut the client down when it's not used anymore?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              schabe77 Christian Habermehl
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: