首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >造成内存溢出的计时器开销

造成内存溢出的计时器开销
EN

Stack Overflow用户
提问于 2016-02-19 18:38:15
回答 1查看 420关注 0票数 1

来自timer.Stop() 文档

停止阻止计时器开火。如果调用停止计时器,则返回true;如果计时器已过期或已停止,则返回false。停止不关闭通道,以防止从通道读取不正确成功。

我需要找到一种方法来摧毁定时器对象或通道在程序中创建通过之后NewTimer。我不直接使用这些函数,只是使用这些函数实现超时的另一个库。我处理程序内存的请求越多,就会不断增加,然后就会被杀死。

我曾查过以下地方,但没有多少帮助:

  1. 0P8
  2. ZRqU
  3. https://groups.google.com/forum/#!topic/golang-nuts/rYthykbCLHk
  4. https://groups.google.com/forum/#!topic/golang-nuts/hjioKxSJ3Tc

请帮帮忙,急需解决这个问题。

更新

可疑代码在https://github.com/gocql/gocql/blob/986e33a705412161497203d55d0669d04282f5ff/conn.go#L546

代码语言:javascript
复制
var timeoutCh <-chan time.Time
if c.timeout > 0 {
    timeoutCh = time.After(c.timeout)
}

select {
case err := <-call.resp:
    if err != nil {
        if !c.Closed() {
            // if the connection is closed then we cant release the stream,
            // this is because the request is still outstanding and we have
            // been handed another error from another stream which caused the
            // connection to close.
            c.releaseStream(stream)
        }
        return nil, err
    }
case <-timeoutCh:
    close(call.timeout)
    c.handleTimeout()
    return nil, ErrTimeoutNoResponse
case <-c.quit:
    return nil, ErrConnectionClosed
}

我怎么知道这个?我运行go工具pprof来捕获memprof,它显示的是:

EN

回答 1

Stack Overflow用户

发布于 2016-02-20 15:47:26

我已经合并了一个修复程序,如果您遇到进一步的问题,https://github.com/gocql/gocql/pull/661请提出一个问题

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35512541

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档