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 reactivePoll leak #2522
Merged
Merged
Fix reactivePoll leak #2522
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jcheng5
reviewed
Jul 26, 2019
jcheng5
reviewed
Jul 26, 2019
wch
commented
Aug 26, 2019
After in-person discussion: Let's change the finalizer to merely set a boolean variable, that the observer will look at and destroy itself when it is set to |
wch
force-pushed
the
wch-fix-reactivepoll-leak
branch
from
August 27, 2019 01:58
2bd5fa9
to
6821972
Compare
jcheng5
reviewed
Aug 28, 2019
jcheng5
requested changes
Aug 28, 2019
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.
The missing return()
jcheng5
approved these changes
Sep 5, 2019
jcheng5
requested changes
Sep 5, 2019
jcheng5
force-pushed
the
wch-fix-reactivepoll-leak
branch
from
September 5, 2019 23:15
f1ee11d
to
33c5a5c
Compare
jcheng5
approved these changes
Sep 5, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #1548. It allows
reactivePoll
objects to clean up when there are no longer any references to them.Note that there must no longer be any references to the
reactivePoll
object for it to be cleaned up. If there's still a reference to the object, even if that reference isn't consumed by any other reactives/observers, that's not sufficient for it to be cleaned up; in other words, it will keep firing.Example app:
Here's how it behaves before this PR:
And after this PR:
Note that before the change, the replacement reactive, which has the value
"count() has been replaced"
, shows up inoutput$count
, but after the change, it doesn't. This is because, before the change, the invalidation keeps happening on the timer and causes therenderText
to re-execute; but after the change, the invalidation stops happening aftercount()
is replaced, so it does not cause therenderText
to re-execute.Here's a test that works outside of a Shiny app:
Update: With the final version of this PR, in test app,
i()
will go one number higher thancount
-- what's important is thati()
stops at some point. Also, in the test code for outside of a Shiny app, it should check forstopifnot(i == 3)
(this is in the unit tests in the PR).