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 thread leak due to Timer
being created and never cancelled
#2131
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2131 +/- ##
=========================================
Coverage 80.93% 80.94%
- Complexity 3254 3257 +3
=========================================
Files 231 231
Lines 11951 11957 +6
Branches 1586 1588 +2
=========================================
+ Hits 9673 9679 +6
Misses 1698 1698
Partials 580 580
Continue to review full report at Codecov.
|
@@ -54,6 +55,11 @@ final class LifecycleWatcher implements DefaultLifecycleObserver { | |||
this.enableAppLifecycleBreadcrumbs = enableAppLifecycleBreadcrumbs; | |||
this.hub = hub; | |||
this.currentDateProvider = currentDateProvider; | |||
if (enableSessionTracking) { | |||
timer = new Timer(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure where we could call cancel on the timer here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on Android briefly, looked good, thanks for doing this!
📜 Description
Timer
was created for every transaction which caused a new thread to be spawned each time. With this PR theTimer
is only created inSentryTracer
ifidleTimeout
is set there. When the transaction is finished, the timer is cancelled.💡 Motivation and Context
Fixes #2115
💚 How did you test it?
📝 Checklist
🔮 Next steps