Skip to content

time: stop time.Ticker when it is garbage collected #8001

Closed
@gopherbot

Description

@gopherbot

by awawfumin:

Go version:

> go version
go version go1.2.2 darwin/amd64

After reading the source code http://golang.org/src/pkg/runtime/time.goc , and later
confirmed by Ian Lance Taylor
https://groups.google.com/d/msg/golang-nuts/Chx1tCs2QGg/EbEOnm18NF0J , the current
implementation of time.Ticker would leak memory in the global structure
"timers" if the Ticker is no longer referenced.

We should preferably Stop() a Ticker when it is garbage collected, or if that is
technically not feasible at the moment, at least document in
http://golang.org/pkg/time/#Ticker much like how it is emphasized to call Close() after
reading from resp.Body http://golang.org/pkg/net/http/#Client.Get .

More info about the problem, plus several possible implementation proposals (to date
none are satisfactory) can be found in
https://groups.google.com/forum/#!topic/golang-nuts/Chx1tCs2QGg

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions