Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid leaking ticker #2839

Closed
wants to merge 1 commit into from
Closed

Avoid leaking ticker #2839

wants to merge 1 commit into from

Conversation

jech
Copy link
Member

@jech jech commented Aug 1, 2024

A ticker needs to be explicitly stopped when it's no longer
useful.

A ticker needs to be explicitly stopped when it's no longer
useful in order to avoid a resource leak.
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.36%. Comparing base (35b3ae1) to head (d0b2289).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2839      +/-   ##
==========================================
+ Coverage   78.91%   79.36%   +0.44%     
==========================================
  Files          89       89              
  Lines        8314     8479     +165     
==========================================
+ Hits         6561     6729     +168     
+ Misses       1276     1271       -5     
- Partials      477      479       +2     
Flag Coverage Δ
go 80.95% <ø> (+0.45%) ⬆️
wasm 64.88% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Sean-Der
Copy link
Member

Sean-Der commented Aug 1, 2024

We have this anti-pattern in a few examples :/

Mind updating the other examples also? If you don't have the time I can grab it.

Hopefully this bad code hasn't ended up in too many other code bases :/

Sorry did 'Comment and Close' instead of just comment

@Sean-Der Sean-Der closed this Aug 1, 2024
@Sean-Der Sean-Der reopened this Aug 1, 2024
@jech
Copy link
Member Author

jech commented Aug 1, 2024

Mind updating the other examples also? If you don't have the time I can grab it.

I'll see what I can do, no promises.

Hopefully this bad code hasn't ended up in too many other code bases :/

It's not that bad: in Go 1.23 and later, the bug has been solved, an orphaned ticker will eventually be garbage collected. However, it's still more thrifty to call Stop as early as possible.

@jech jech mentioned this pull request Aug 1, 2024
@jech
Copy link
Member Author

jech commented Aug 1, 2024

Superseded by #2843.

@jech jech closed this Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants