为什么当我初始化 ticker 然后更新它时,原始的 ticker 仍然存在于内存中,如果我进行循环,它会很快杀死我的 RAM
timeOut := 10
ticker := time.NewTicker(time.Duration(timeOut) * time.Second)
for {
ticker = time.NewTicker(time.Duration(timeOut) * time.Second)
}
最佳答案
import "time"
func NewTicker(d Duration) *Ticker
NewTicker returns a new Ticker containing a channel that will send the time with a period specified by the duration argument. It adjusts the intervals or drops ticks to make up for slow receivers. The duration d must be greater than zero; if not, NewTicker will panic. Stop the ticker to release associated resources.
按照说明:停止自动收报机以释放相关资源。
关于go - 股票代码仍然存在于内存中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53935464/