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

fix: memory leakage #24

Closed
wants to merge 1 commit into from
Closed

fix: memory leakage #24

wants to merge 1 commit into from

Conversation

cfanbo
Copy link
Contributor

@cfanbo cfanbo commented Jan 4, 2022

Summary

FIX memory leakage

timer.After: https://cs.opensource.google/go/go/+/refs/tags/go1.17.5:src/time/sleep.go;l=154-159

Checklist

  • reference any related issues
  • updated docs
  • updated unit tests
  • updated UPGRADING.md
  • add appropriate tag (improvement / bug / etc)
  • ready for review

@cfanbo cfanbo requested a review from a team as a code owner January 4, 2022 11:14
@calebdoxsey
Copy link
Contributor

I don't think this will work. Reading the docs:

It is not safe to manipulate the
provided backoff policy (notably calling NextBackOff or Reset)
while the ticker is running.

We call .Reset.

time.After can leak, but only if it doesn't fire:

The underlying Timer is not recovered by the garbage collector until the timer fires.

In the case of this code I believe the timer will almost always fire since ctx.Done happens when the program terminates.

Were you seeing a memory leak in practice? Maybe there's some other cause?

@cfanbo cfanbo closed this Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants