HelloSmallSnail opened a new issue, #11465:
URL: https://github.com/apache/dubbo/issues/11465

   <!-- If you need to report a security issue please visit 
https://github.com/apache/dubbo/security/policy -->
   
   - [ ] 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
   近期在生产环境发现有部分消费方节点内存占用比较大,这些节点基于Dubbo 
2.5.9开发,在业务上类似服务组合层,它们要订阅上千个服务,并且下游提供方集群的规模也比较大。我们对这些消费方节点的内存快照进行了分析,发现URL对象的体积很大,其中订阅服务相关的URL对象(path=com.xxx.yyyService)约有370MB,其数量也达到了13万+。
   
   我们的基本环境信息是:
   Dubbo版本:2.5.9
   JDK版本:IBM 1.8
   操作系统:Linux
   
   在分析过程中,我们遇到两个问题,希望求助社区。
   1. 我们发现如下两个缓存中占用体积较大,缓存存放的都是URL对象,想问下这两个缓存的作用是什么,不知是否可以去掉以节约内存?
       
**com.alibaba.dubbo.registry,integration.RegistryDirectory#cachedInvokerUrls
       com.alibaba.dubbo.registry.support.AbstractRegistry#notified**
   
   2. 我们对比两个内存快照,发现同一个URL对象中的部分参数,其内容没有变化,但是Retained 
Heap大小变大了,而且这种现象非常普遍。以URL对象的parameters属性中的methods参数为例,在图1中它的retained 
Heap=24B,在图2中变成了1864B=24B+16B+1824B。进一步查看对象的Incoming 
Reference发现,图1中字符串被两个Node对象持有(见图3),故这两个字符串的大小不算入任一Node的RetainedHeap中,而在图2中字符串只被当前这个Node对象持有(见图4),导致RetainedHeap增大了。
       我们有疑问的是:
       **1)提供方集群没有变动的情况下,消费方的URL对象为何会更新?
       2)URL对象中的字符串内容,为何会从多Node共享变成独占?**
   
   图1:methods参数的retained Heap=24B
   
![image](https://user-images.githubusercontent.com/20399234/216879298-b1c92346-f238-42ba-973d-dc2897084690.png)
   
   图2:methods参数的retained Heap=1864B
   
![image](https://user-images.githubusercontent.com/20399234/216879438-0eb9992e-0c36-46fb-8cd0-4f351ee2f991.png)
   
   图3:字符串被两个Node对象持有
   
![image](https://user-images.githubusercontent.com/20399234/216879658-13cf9001-6949-42c2-9f2a-1373ab46fa8c.png)
   
   图4:字符串为当前Node对象独占
   
![image](https://user-images.githubusercontent.com/20399234/216879779-ed8a7ad4-4694-4b29-9a10-a1a5b535d500.png)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to