Describe the bug
Setting the AncestorType property on an object will store the parent of the object as an attached property, causing a reference loop (the parent holds a reference to the child, the child holds a reference to the parent).
Steps to Reproduce
Steps to reproduce the behavior:
- Use AncestorType in some XAML content
- Load the XAML content (eg navigate to it in a frame)
- Unload the XAML content (eg navigate away from it, remove it from the visual tree)
- Notice that the XAML elements are never freed correctly, keep taking memory, and weak references will still resolve.
Expected behavior
The elements should be freed.
Screenshots
No screenshots needed.
Environment
NuGet Package(s): N/A
Package Version(s): N/A
Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [x] May 2020 Update (19041)
- [ ] Insider Build (build number: )
App min and target version:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [x] May 2020 Update (19041)
- [x] Insider Build (22000)
Device form factor:
- [x] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT
Visual Studio
- [ ] 2017 (version: )
- [ ] 2019 (version: )
- [ ] 2019 Preview (version: )
- [x] 2022 Preview (version 17.0 preview 2.1)
Additional context
Found while doing a C++ port, so bug happens on latest commit. The solution to this issue would be to set the Ancestor attached property to null in the Unloaded event handler.
Describe the bug
Setting the
AncestorTypeproperty on an object will store the parent of the object as an attached property, causing a reference loop (the parent holds a reference to the child, the child holds a reference to the parent).Steps to Reproduce
Steps to reproduce the behavior:
Expected behavior
The elements should be freed.
Screenshots
No screenshots needed.
Environment
Additional context
Found while doing a C++ port, so bug happens on latest commit. The solution to this issue would be to set the
Ancestorattached property tonullin theUnloadedevent handler.