瀏覽代碼

conn: fix memory leak when using long timeouts

A timer will only be garbage collected once it has fired, if a call
returns before the timeout is reached then it will not be garbage
collected, leading to potentially many timers on the heap.

fixes #851
Chris Bannister 9 年之前
父節點
當前提交
016a613b83
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      conn.go

+ 4 - 0
conn.go

@@ -536,6 +536,10 @@ func (c *Conn) releaseStream(stream int) {
 	delete(c.calls, stream)
 	c.mu.Unlock()
 
+	if call.timer != nil {
+		call.timer.Stop()
+	}
+
 	streamPool.Put(call)
 	c.streams.Clear(stream)
 }