-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Set Schedulers removeOnCancelPolicy to avoid task memory leak #1674
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
Conversation
Codecov Report
@@ Coverage Diff @@
## 3.2.x #1674 +/- ##
============================================
+ Coverage 84.29% 84.31% +0.02%
- Complexity 3908 3913 +5
============================================
Files 360 360
Lines 29940 29957 +17
Branches 5573 5575 +2
============================================
+ Hits 25237 25259 +22
Misses 3072 3072
+ Partials 1631 1626 -5
Continue to review full report at Codecov.
|
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.
Looks good, we might want to benchmark with that - WDYT @akarnokd ? I guess it has some impact and that's why we might explore a separate batch-purge thread as well.
Purge is more efficient but you need a periodic task possibly on another scheduled executor to initiate cleanup. |
I have committed some new changes that purge ScheduledThreadPoolExecutor on another scheduled executor. Maybe this is better? |
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.
I'd prefer to revert the last commit and go back to the cancellation policy implementation for a start
@aftersss we can go back to the purge-thread based version at a later time, maybe with some microbenchmarking to see how much of a difference it makes to see if the added complexity is worth it. |
…up purging" This reverts commit a5b4dd9.
@aftersss this PR seems to have been merged on a maintenance branch, please ensure the change is merge-forwarded to |
Although a purge background thread could be more efficient, it would also be more complex, so this is a good first approach.
If we run the following code(with jvm args
-Xmx10m -Xms10m
), we will soon meetjava.lang.OutOfMemoryError: GC overhead limit exceeded
:And I found that the key point is that
ScheduledThreadPoolExecutor.removeOnCancelPolicy
's default value is false, I think the default value should be true to avoid memory leak.