Skip to content

Instantly share code, notes, and snippets.

@gkampitakis
Created February 18, 2024 14:20
Show Gist options
  • Save gkampitakis/7405b99701bacc6e02576ffdcf16a34f to your computer and use it in GitHub Desktop.
Save gkampitakis/7405b99701bacc6e02576ffdcf16a34f to your computer and use it in GitHub Desktop.
Memory leaks in Go - Not stopping time.Ticker
func main() {
for {
ticker := time.NewTicker(1 * time.Second)
// do something with the ticker
_ = <-ticker.C
// stop the ticker to release associated resources
ticker.Stop()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment