SfCarousel handler and platform view remain in memory after closing the page (iOSMac) - #412
Closed
TameemAnsari-SF4702 wants to merge 1 commit into
Closed
TameemAnsari-SF4702 wants to merge 1 commit into
TameemAnsari-SF4702 wants to merge 1 commit into
Conversation
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.
Root Cause of the Issue
The SfCarousel control’s handler and its associated platform view are not getting released from memory after the page containing the control is closed. This leads to memory retention and potential memory leaks when navigating repeatedly between pages.
The issue is reproducible in a sample application where instance counting is used to track whether objects are properly disposed.
Handler not set null when disconnect. The native PlatformCarousel retained strong references through internal native object relationships, preventing timely garbage collection after page disposal.
Description of Change
Need to set null for handler in Disconnect when the app closing. Updated the PlatformCarousel cleanup logic during disconnection to explicitly release native references and break the retention chains.
The fix includes:
Removing the registered gesture recognizer from the carousel during disconnect.
Clearing InternalCarousel references from all PlatformCarouselItem instances.
Releasing handler references after native cleanup is completed.
Ensuring native carousel items no longer hold references to the parent carousel once the page is closed.
This cleanup allows the PlatformCarousel instance to become eligible for garbage collection after navigation, preventing memory accumulation during repeated page open/close operations on iOS and Mac Catalyst.