Fixed multiple memory leaks across components#795
Merged
Conversation
…, SearchBarHandler, and SlidableLayout Co-authored-by: Vetle444 <35739538+Vetle444@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Identify possible memory leaks in the application
Fix memory leaks from missing event unsubscriptions
Feb 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses multiple memory-leak vectors across DIPS.Mobile.UI components/handlers by ensuring event subscriptions, timers, animations, and native callbacks are properly cleaned up when views/handlers are disconnected or rebuilt.
Changes:
- Replaced anonymous event handlers (lambdas/delegates) with named methods to enable reliable unsubscription and prevent captured references.
- Added missing event unsubscriptions / disposal (e.g., iOS camera preview events, timers, Android native callbacks, gesture recognizers).
- Improved handler-lifecycle alignment for subscriptions (moving subscribe/unsubscribe to
OnHandlerChanged/OnHandlerChangingwhere appropriate).
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/library/DIPS.Mobile.UI/Components/TabView/iOS/TabView.cs | Replaces anonymous tab tap handler with named method and unsubscribes in ClearItems(). |
| src/library/DIPS.Mobile.UI/Components/Slidable/SlidableLayout.cs | Stores tap recognizer as a field and unsubscribes on handler disconnect. |
| src/library/DIPS.Mobile.UI/Components/Shell/Shell.cs | Unsubscribes Navigated on handler disconnect to avoid lingering references. |
| src/library/DIPS.Mobile.UI/Components/Searching/SearchPage.cs | Moves TextChanged subscription to handler lifecycle and unsubscribes on handler disconnect. |
| src/library/DIPS.Mobile.UI/Components/Pickers/SegmentedControl/SegmentedControl.cs | Replaces anonymous SizeChanged handler with named method. |
| src/library/DIPS.Mobile.UI/Components/Pickers/ScrollPicker/Android/ScrollPickerHandler.cs | Disposes ScrollPickerViewModel on handler disconnect. |
| src/library/DIPS.Mobile.UI/Components/Pickers/NullableDatePickerShared/BaseNullableDatePicker.cs | Unsubscribes switch Toggled on handler disconnect. |
| src/library/DIPS.Mobile.UI/Components/Pickers/ItemPicker/ItemPicker.cs | Unsubscribes CollectionChanged from old ItemsSource before subscribing to new. |
| src/library/DIPS.Mobile.UI/Components/Pickers/DatePickerShared/iOS/BaseDatePickerHandler.cs | Adds missing ValueChanged unsubscription on disconnect. |
| src/library/DIPS.Mobile.UI/Components/Navigation/FloatingNavigationButton/FloatingNavigationButtonService.cs | Clears static FAB reference on Remove() to allow GC. |
| src/library/DIPS.Mobile.UI/Components/Navigation/FloatingNavigationButton/Android/FloatingNavigationButtonHandler.cs | Replaces anonymous click handler with named method and prevents duplicate subscriptions. |
| src/library/DIPS.Mobile.UI/Components/Loading/StateView/StateView.cs | Tracks previous StateViewModel to unsubscribe old OnStateChanged. |
| src/library/DIPS.Mobile.UI/Components/Loading/Skeleton/SkeletonView.cs | Stops animation when handler disconnects to avoid repeat callbacks retaining the view. |
| src/library/DIPS.Mobile.UI/Components/BottomSheets/Android/BottomSheetHandler.cs | Stores/removes native callback/listener instances to prevent Java-side GC roots. |
| src/library/DIPS.Mobile.UI/Components/Alerting/SystemMessage/SystemMessage.cs | Disposes the timer in Dispose(). |
| src/library/DIPS.Mobile.UI/API/Camera/Shared/iOS/CameraSession.cs | Unsubscribes PreviewView.OnTapToFocus when stopping session. |
| src/library/DIPS.Mobile.UI/API/Camera/Gallery/BottomSheet/GalleryBottomSheet.cs | Replaces anonymous SizeChanged handlers with named methods and unsubscribes appropriately. |
| CHANGELOG.md | Adds a patch release entry documenting leak fixes. |
| build/bootstrapper/bootstrapper.sh | Fixes Azure CLI presence check to silence stderr. |
src/library/DIPS.Mobile.UI/Components/Pickers/SegmentedControl/SegmentedControl.cs
Show resolved
Hide resolved
...library/DIPS.Mobile.UI/Components/Pickers/NullableDatePickerShared/BaseNullableDatePicker.cs
Show resolved
Hide resolved
haavamoa
approved these changes
Apr 8, 2026
eirinsvi
reviewed
Apr 8, 2026
src/library/DIPS.Mobile.UI/Components/Pickers/SegmentedControl/SegmentedControl.cs
Show resolved
Hide resolved
…e replaced or handler disconnects Agent-Logs-Url: https://github.com/DIPSAS/DIPS.Mobile.UI/sessions/0ff7e0eb-4f90-4086-82a6-b6528e2a7d38 Co-authored-by: Vetle444 <35739538+Vetle444@users.noreply.github.com>
auto-merge was automatically disabled
April 8, 2026 10:04
Head branch was pushed to by a user without write access
Copilot stopped work on behalf of
Vetle444 due to an error
April 8, 2026 10:05
This file contains hidden or 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
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.
CameraSession.cs(iOS):PreviewView.OnTapToFocusevent never unsubscribed inStopCameraSession()SearchBarHandler.cs(iOS): Wrong event unsubscribed -SearchButtonClickedhandler unsubscribed fromCancelButtonClickedinstead ofSearchButtonClickedSlidableLayout.cs:TapGestureRecognizer.Tappedevent never unsubscribed due to missing field referenceSegmentedControl.cs:border.SizeChangedevent never unsubscribed when items replaced or handler disconnects