Skip to content

[TECHNICAL] Resource leaks in fragment bindings#4814

Open
corevibe555 wants to merge 1 commit intoowncloud:masterfrom
corevibe555:technical/binding_resource_leaks
Open

[TECHNICAL] Resource leaks in fragment bindings#4814
corevibe555 wants to merge 1 commit intoowncloud:masterfrom
corevibe555:technical/binding_resource_leaks

Conversation

@corevibe555
Copy link
Copy Markdown

@corevibe555 corevibe555 commented Mar 31, 2026

Related Issues

Fixes #4813

Description

Set _binding = null in onDestroyView() for 10 fragments that were missing cleanup, preventing memory leaks when fragment instances outlive their views.

Affected fragments:

  • CreateShortcutDialogFragment
  • FileDetailsFragment
  • MainEmptyListFragment
  • RemoveFilesDialogFragment
  • SharesFragment
  • SpacesListFragment
  • CreateSpaceDialogFragment
  • AddMemberFragment
  • SpaceMembersFragment
  • SetSpaceIconDialogFragment

App:

  • Add changelog files for the fixed issues in folder changelog/unreleased. More info here
  • Add feature to Release Notes in ReleaseNotesViewModel.kt creating a new ReleaseNote() with String resources (if required)

QA

  • Verify app builds without errors
  • Navigate in and out of each affected fragment and confirm no crashes

@corevibe555 corevibe555 changed the title fix: clear view binding references in onDestroyView to prevent memory… [FIX]: clear view binding references in onDestroyView to prevent memory… Mar 31, 2026
@corevibe555
Copy link
Copy Markdown
Author

@joragua Here is another small PR.
Would you please review when you have a chance?

Thanks!

@joragua
Copy link
Copy Markdown
Collaborator

joragua commented Mar 31, 2026

Thanks for the contribution @corevibe555! 🙌🏻 I will check this PR as soon as possible and give you any feedback if necessary. Stay tuned!

@joragua joragua changed the title [FIX]: clear view binding references in onDestroyView to prevent memory… [TECHNICAL] Resource leaks in fragment bindings Apr 1, 2026
Copy link
Copy Markdown
Collaborator

@joragua joragua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job @corevibe555! 🍻 Some comments about this PR

  1. I'd split this into two separate commits: one for the calens entry (chore: add calens file or chore: add changelog) and another one for the implementation (keeping the same name)

  2. Regarding changelog file: missing PR link at the end of the file. In addition, the name of the file must be the PR id (in this case: 4814)

  3. After rebasing the branch against master, there are more fragments that need binding cleanup. Also, there is an extra point in this PR: onDestroy() methods that only handle binding cleanup should be replaced with onDestroyView(). There are three fragments currently clearing the binding in onDestroy(): TransfersListFragment, SortBottomSheetFragment, and MainFileListFragment

Comment on lines +1 to +5
Bugfix: Resource leaks in fragment view bindings

View binding references have been cleared in onDestroyView() across 10 fragments to prevent memory leaks when fragment instances outlive their views.

https://github.com/owncloud/android/issues/4813
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change the calens file like this:

Suggested change
Bugfix: Resource leaks in fragment view bindings
View binding references have been cleared in onDestroyView() across 10 fragments to prevent memory leaks when fragment instances outlive their views.
https://github.com/owncloud/android/issues/4813
Enhancement: Resource leaks in fragment view bindings
View binding references have been cleared in onDestroyView() across fragments to prevent memory leaks when fragment instances outlive their views.
https://github.com/owncloud/android/issues/4813

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.

[TECHNICAL] Resource leaks in fragment bindings

2 participants