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

Stop timer when it's no longer needed #109

Closed
wants to merge 1 commit into from

Conversation

justinmayhew
Copy link

When a batch is triggered by hitting the batch capacity, the timer is no longer needed and the resources associated with it can be released.

When a batch is triggered by hitting the batch capacity, the timer is no
longer needed and the resources associated with it can be released.
@rwrz
Copy link

rwrz commented Sep 10, 2024

It was important before Go 1.23, now it is not anymore [ref]:

Before Go 1.23, this documentation warned that the underlying Timer would not be recovered by the garbage collector until the timer fired, and that if efficiency was a concern, code should use NewTimer instead and call Timer.Stop if the timer is no longer needed. As of Go 1.23, the garbage collector can recover unreferenced, unstopped timers. There is no reason to prefer NewTimer when After will do.

@justinmayhew
Copy link
Author

Closing as no longer needed.

@justinmayhew justinmayhew deleted the stop-timer branch September 11, 2024 13:53
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.

2 participants