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

Memory Leak from time.After #1761

Closed
lukemin89 opened this issue Nov 24, 2022 · 2 comments · Fixed by #1802
Closed

Memory Leak from time.After #1761

lukemin89 opened this issue Nov 24, 2022 · 2 comments · Fixed by #1802
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@lukemin89
Copy link

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Is this a client library issue or a product issue? We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the Support page to reach the most relevant engineers.

If the support paths suggested above still do not result in a resolution, please provide the following details.

Environment details

  • Programming language: Golang
  • OS: MacOS
  • Language runtime version: 1.18
  • Package version: ?

Steps to reproduce

quitAfter := time.After(retryDeadline)

case <-time.After(pause):

There are other places that use time.After.
If using with long retryDeadline, the memory usage keeps increasing.

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@lukemin89 lukemin89 added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Nov 24, 2022
@quartzmo
Copy link
Member

From: https://pkg.go.dev/time#After

The underlying Timer is not recovered by the garbage collector until the timer fires. If efficiency is a concern, use NewTimer instead and call Timer.Stop if the timer is no longer needed.

@codyoss
Copy link
Member

codyoss commented Nov 29, 2022

cc @tritone

codyoss added a commit to codyoss/google-api-go-client that referenced this issue Jan 6, 2023
Can reduce memory usuage for stacking timers that are not gc'ed in
retry loops.

Fixes: googleapis#1761
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants