apache / apache/dubbo

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

Open
#11,218 2 comments 0 reactions 0 assignees View on GitHub
status/waiting-for-feedback
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

- [ ] I have searched the [issues](https://github.com/apache/dubbo/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 service = new ServiceConfig<>();
service.setInterface("**");
service.setRef(genericService);
service.setGeneric("true");
service.export();`

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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the generic-service lifecycle described with ServiceConfig, export(), and unexport(), then trace references from ServiceRepository.services and providers after destroy(). Check whether other references retain MyGenericService or ServiceConfig, and define completion as confirming the retention path or documenting that no leak remains after garbage collection.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.