dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

通过泛化实现暴露的服务,注销服务时MyGenericService对象不回收

Open ZouYicheng opened this issue 2 years ago • 1 comments

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.

Ask your question here

我在做一个通过泛化实现和泛化调用实现类似网关的项目。即把MyGenericService服务暴露成自定义接口名。当接口弃用时把该服务注销。但我发现注销后MyGenericService对象没有回收。我担心随着服务越来越多,内存占用越来越多发生oom。

泛化实现定义了含$invoke方法的MyGenericService。暴露服务时: GenericService genericService = new MyGenericService(); ServiceConfig<GenericService> service = new ServiceConfig<>(); service.setInterface("**"); service.setRef(genericService); service.setGeneric("true"); service.export();

注销服务时调用了service.unexport(),并且执行了GC。但genericService和service对象没有回收掉。 我发现ServiceRepository类中的services和providers中有相关引用,但我调用destroy清空后还是没有回收对象。还有其他位置有相关引用么?

ZouYicheng avatar Dec 29 '22 02:12 ZouYicheng

升级到 3.1.4 版本后还有吗

AlbumenJ avatar Dec 30 '22 08:12 AlbumenJ

是不是ReferenConfig没有destroy,我发现referenceConfig和genericService之间有循环引用,所以无法gc掉

Charcla avatar Dec 19 '23 01:12 Charcla