Repository navigation
Description
Description
PathGeometry.Figures.Clear() does not appear to unsubscribe cleared PathFigure instances from the owning PathGeometry. If a PathFigure is shared/rooted elsewhere, the cleared figure can retain the page-local PathGeometry, which then retains the Path through InvalidatePathGeometryRequested, and the Path retains its BindingContext.
Repro project:
Leak path shown by the repro:
shared PathFigure -> PropertyChanged delegate -> page-local PathGeometry -> InvalidatePathGeometryRequested delegate -> Path -> BindingContext payload
The repro runs three scenarios:
control:
page-local PathFigure + PathGeometry.Figures.Clear()
leaky:
shared/rooted PathFigure + PathGeometry.Figures.Clear()
mitigation:
shared/rooted PathFigure + PathGeometry.Figures.RemoveAt(0)
Observed on iOS simulator:
control:
Payload view models retained: 0/50
Paths retained: 0/1200
PathGeometry instances retained: 0/1200
leaky:
Payload view models retained: 50/50
Paths retained: 1200/1200
PathGeometry instances retained: 1200/1200
Retained payload bytes: 209715200 (200.00 MiB)
mitigation:
Payload view models retained: 0/50
Paths retained: 0/1200
PathGeometry instances retained: 0/1200
Expected behavior: Figures.Clear() should unsubscribe removed figures the same way indexed removal does, allowing the page-local PathGeometry, Path, and payload graph to be collected.
Steps to Reproduce
- Clone the repro branch:
git clone --branch repro/pathgeometry-figures-clear-leak https://github.com/AdamEssenmacher/maui.git maui-pathgeometry-repro
cd maui-pathgeometry-repro- Build MAUI build tasks:
dotnet build Microsoft.Maui.BuildTasks.slnf- Build the repro app for an iOS simulator:
dotnet build src/Controls/samples/PathGeometryFiguresClearLeakRepro/PathGeometryFiguresClearLeakRepro.csproj \
-f net10.0-ios \
-p:RuntimeIdentifier=iossimulator-arm64- Pick and boot an iOS simulator:
xcrun simctl list devices available
UDID=<simulator-udid>
xcrun simctl boot "$UDID"
xcrun simctl bootstatus "$UDID"- Install and launch the autorun repro:
xcrun simctl install "$UDID" \
artifacts/bin/PathGeometryFiguresClearLeakRepro/Debug/net10.0-ios/iossimulator-arm64/PathGeometryFiguresClearLeakRepro.app
xcrun simctl launch --terminate-running-process "$UDID" \
com.microsoft.maui.pathgeometryfiguresclearleakrepro \
--auto-run --target=PathGeometryFigures- Read the generated report:
APP_CONTAINER=$(xcrun simctl get_app_container "$UDID" com.microsoft.maui.pathgeometryfiguresclearleakrepro data)
cat "$APP_CONTAINER/Library/PathGeometryFiguresClearLeakRepro/autorun-results.txt"Expected Result
control, leaky, and mitigation should all release popped page payloads, Path controls, and page-local PathGeometry instances after forced full GC.
Actual Result
Only the shared PathFigure + PathGeometry.Figures.Clear() scenario retains the payload graph:
shared PathFigure -> PropertyChanged delegate -> page-local PathGeometry -> InvalidatePathGeometryRequested delegate -> Path -> BindingContext payload
Observed result:
control:
Payload view models retained: 0/50
Paths retained: 0/1200
PathGeometry instances retained: 0/1200
leaky:
Payload view models retained: 50/50
Paths retained: 1200/1200
PathGeometry instances retained: 1200/1200
Retained payload bytes: 209715200 (200.00 MiB)
mitigation:
Payload view models retained: 0/50
Paths retained: 0/1200
PathGeometry instances retained: 0/1200
Link to public reproduction project repository
Version with bug
10.0.70
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
No response
Activity
NafeelaNazhir commentedon Jun 9, 2026
This issue has been validated in Visual Studio Code 1.123.0 with .NET MAUI versions 9.0.0, 10.0.0 & 10.0.70. It was reproducible on iOS, Android platform.
Screen.Recording.2026-06-09.at.11.45.46.AM.mov
Screen.Recording.2026-06-09.at.11.42.40.AM.mov
Fix for PathGeometry.Figures.Clear() leaks when clearing shared PathF…
Fix for PathGeometry.Figures.Clear() leaks when clearing shared PathF…
Fix for PathGeometry.Figures.Clear() leaks when clearing shared PathF…
Fix for PathGeometry.Figures.Clear() leaks when clearing shared PathF…
Fix for PathGeometry.Figures.Clear() leaks when clearing shared PathF…
Fix for PathGeometry.Figures.Clear() leaks when clearing shared PathF…
Fix for PathGeometry.Figures.Clear() leaks when clearing shared PathF…
Fix for PathGeometry.Figures.Clear() leaks when clearing shared PathF…
Fix for PathGeometry.Figures.Clear() leaks when clearing shared PathF…
Fix for PathGeometry.Figures.Clear() leaks when clearing shared PathF…
July 13th, Candidate (#36411)