You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2022/05/31 12:27:03 UTC

[GitHub] [servicecomb-java-chassis] Nick-The-Uncharted opened a new issue, #3025: org.apache.servicecomb.foundation.vertx.client.ClientPoolManager#findByContext可能持续创建HttpClientWithContext导致内存泄漏

Nick-The-Uncharted opened a new issue, #3025:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3025

   ## 复现代码:
   microservice.yaml
   
   ```yaml
   servicecomb:
     executor:
       default:
         group: 1
         coreThreads-per-group: 0
         maxThreads-per-group: 1
         maxIdleSecond-per-group: 1
   ```
   
   
   
   controller:
   
   ```java
       @RpcReference(microserviceName = "xxx", schemaId = "xxx")
       protected XXXProxy xxxProxy;
   
       @GetMapping("/test")
       public void test(){
           otaTaskOperateProxy.collectLog("asd", "sd").whenComplete((d, e) -> otaTaskOperateProxy.collectLog("a", "b"));
       }
   ```
   
   
   
   每隔1s发送一次请求,就会发现org.apache.servicecomb.foundation.vertx.client.ClientPoolManager#pools一直在增长。
   
   
   
   由于HttpClient里有证书相关的信息,贼大(几百k),很快就把内存占满,引发疯狂fullGC
   
   
   
   ## 分析:
   
   * test接口第一次发送请求io.vertx.core.http.impl.HttpClientImpl#request(io.vertx.core.http.RequestOptions) 时由于当前线程是类似"group0-1-thread-2"@19,463 in group "main": RUNNING 的线程 没有context所以io.vertx.core.impl.VertxImpl#getOrCreateContext新建了context, 类似这样的线程默认一共有25(core)~100(max)个
   * 请求的响应使用的context就为第一步新建的context, io.vertx.core.impl.future.FutureBase#emitSuccess
   * org.apache.servicecomb.foundation.vertx.client.ClientPoolManager#findByContext(io.vertx.core.Context) 创建HttpClientWithContext **并且加入pool里**
   * 如果线程保持稳定 那么其实创建的context数量最多为线程数(context会缓存在threadLoca io.vertx.core.impl.VertxImpl#stickyContextl里),但是由于线程数是25~100,繁忙时创建的线程可以被释放,所以一直会有context被创建然后引用。
   
   
   
   ## 临时规避方案
   
   设置servicecomb.executor.default.maxThreads-per-group为25(同servicecomb.executor.default.coreThreads-per-group)
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #3025: org.apache.servicecomb.foundation.vertx.client.ClientPoolManager#findByContext可能持续创建HttpClientWithContext导致内存泄漏

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #3025:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3025#issuecomment-1209305934

   fixed


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 closed issue #3025: org.apache.servicecomb.foundation.vertx.client.ClientPoolManager#findByContext可能持续创建HttpClientWithContext导致内存泄漏

Posted by GitBox <gi...@apache.org>.
liubao68 closed issue #3025: org.apache.servicecomb.foundation.vertx.client.ClientPoolManager#findByContext可能持续创建HttpClientWithContext导致内存泄漏
URL: https://github.com/apache/servicecomb-java-chassis/issues/3025


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org