Closed as not planned
Closed as not planned
Description
Describe the bug
Garbage Collector is not disposing Avalonia controls containing nested controls coming from another UserControl classes and turned invisible resulting on memory leaks.
To Reproduce
Steps to reproduce the behavior:
- Run the AvaloniaLeakSample application
[email protected]:LongoMatch/AvaloniaLeakSample.git
- Click on the 'Move to view 2' button
- Click on the 'BACK' button
- Repeat steps 2 & 3 several times until GC disposes unused objects
Expected behavior
Mind the application output. View2
is not being destroyed. You should see "There is no leak on view 1"
and "There is no leak on view 2"
messages several times but only "There is no leak on view 1"
is being displayed.
Screenshots
Environment
- OS: Tested on macOS Sonoma and Windows 10
- Avalonia-Version: 11.0.5
Additional context
Important information:
- Leak on "View 2" happens when using
<sample:NestedControl1>
(which just contains a button) AND settingNestedControl.IsVisible = false;
on the code behind at theOnInitialized ()
method. - Leak also happens when using
<sample:NestedControl1>
AND setting itsIsVisible="False"
property on the XAML file. - Not setting
<sample:NestedControl1>
as invisible or if we just use a<Button>
instead does not leak even if we set that button as not visible on the code behind at theOnInitialized ()
method or the XAML file. - It seems it just happens with the button control. Changing
<Button>
for<Rectangle>
or other controls in the nested control class does not produce the leak