go - 股票代码仍然存在于内存中

标签 go ticker

为什么当我初始化 ticker 然后更新它时,原始的 ticker 仍然存在于内存中,如果我进行循环,它会很快杀死我的 RAM

timeOut := 10
ticker := time.NewTicker(time.Duration(timeOut) * time.Second)
for {
    ticker = time.NewTicker(time.Duration(timeOut) * time.Second)
}

最佳答案

Package time

import "time"

func NewTicker

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/

相关文章:

Go 程序在连接被拒绝后退出

转到目标语言

python - Matplotlib pyplot 坐标轴格式化程序

go - 使用ticker定期从经常变化的路径加载内存中的所有文件?

java - (Java) 添加到计数器变量的代码

go - 中间件执行流程

json - Mongo-go-driver 从插入结果中获取 objectID

json - 是否有 golang 的 jq 包装器可以生成人类可读的 JSON 输出?

html - 图片背后的文字

html - CSS ticker 不能完全工作