Skip to content

[WIP]Fix BackButtonBehavior.Command CanExecuteChanged memory leak - #37771

Draft
devanathan-vaithiyanathan wants to merge 2 commits into
dotnet:mainfrom
devanathan-vaithiyanathan:fix-37635
Draft

[WIP]Fix BackButtonBehavior.Command CanExecuteChanged memory leak#37771
devanathan-vaithiyanathan wants to merge 2 commits into
dotnet:mainfrom
devanathan-vaithiyanathan:fix-37635

Conversation

@devanathan-vaithiyanathan

Copy link
Copy Markdown
Contributor

Issue Details

BackButtonBehavior.Command strongly subscribed to CanExecuteChanged, causing discarded behaviors and their binding contexts to remain in memory.

Description of Change

Updated BackButtonBehavior.Command to use WeakCommandSubscription for CanExecuteChanged. The previous subscription is disposed when the command changes, preventing long-lived commands from retaining discarded behaviors and their binding contexts.

Issues Fixed

Fixes #37635

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac
Before After
iOS
Before.mov
iOS
After.mov

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37771

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37771"

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 24, 2026
@devanathan-vaithiyanathan devanathan-vaithiyanathan added community ✨ Community Contribution and removed partner/syncfusion Issues / PR's with Syncfusion collaboration labels Aug 24, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 24, 2026
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman added the area-controls-shell Shell Navigation, Routes, Tabs, Flyout label Aug 24, 2026
@devanathan-vaithiyanathan devanathan-vaithiyanathan changed the title Fix BackButtonBehavior.Command CanExecuteChanged memory leak [WIP]Fix BackButtonBehavior.Command CanExecuteChanged memory leak Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[leak-scan] BackButtonBehavior.Command — strong CanExecuteChanged subscription retains the behavior

2 participants