-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 memory leak when deleting project #6296
Merged
Merged
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
grzesiek2010
requested changes
Aug 29, 2024
@Named("ADMIN_SETTINGS_STORE") | ||
SettingsStore adminSettingsStore; | ||
String projectId; | ||
Settings adminSettings; |
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.
Those should be private I think.
seadowg
force-pushed
the
project-delete-mem-leak
branch
from
August 29, 2024 11:35
5cc17a6
to
9866b5b
Compare
grzesiek2010
approved these changes
Aug 29, 2024
Tested with Success! Verified on device with Android 10, 14 Verified cases:
|
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.
Closes #6280
I ended up fixing this because I kept running into it while working on something else.
The key problem here was that we tried to unregister our settings listener for fragment like this:
In the case where we delete a project, this ends up getting called after the project has changed meaning that
settingsProvider.getProtectedSettings()
will return a differentSettings
object than was used to register. To prevent this situation, I've made it so that preferences Fragments assign theirSettings
object inonAttach
. As far as I'm aware, there's no reason for this to be looked up each time.Why is this the best possible solution? Were any other approaches considered?
I did consider adding a constructer for
BaseProjectPreferencesFragment
andBaseAdminPreferencesFragment
that would take a project ID rather than needing to do a lookup based onProjectDataService
. That would be more canoncial now that we haveFragmentFactory
. That change would ripple down to many subclasses though, so I felt like it was best to avoid while trying to just make a small fix.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Should just fix the leak!
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still passDateFormatsTest