apache/dubbo-go

release the allocated memory of the ‘url’ field when destroy invoker

Closed this issue · 1 comments

What would you like to be added:

func (bi *BaseInvoker) Destroy() {
logger.Infof("Destroy invoker: %s", bi.GetURL())
bi.destroyed.Store(true)
bi.available.Store(false)
}

here is my question, since the invoker is destroyed ,so why do we not set the url field in invoker to nil ,like below

func (bi *BaseInvoker) Destroy() {
logger.Infof("Destroy invoker: %s", bi.GetURL())
bi.url = nil //add this
bi.destroyed.Store(true)
bi.available.Store(false)
}

Why is this needed:
in this line, the invoker will be add to a global var dubboProtocol

dp.SetInvokers(invoker)

var dubboProtocol *DubboProtocol

so when destroy the invoker, the 'url' is useless and still it cannot be gc(unless destroy the global var),which i think may cause memory leaks