You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that the ItemsRepeater component is causing memory leaks. After some investigation, I have determined that the leaks are due to lingering references to EventHandler in the OnLayoutChanged method.
Desktop/Platform:
OS: Windows (10 / 11)
FluentAvalonia Version (2.1.0 / 2.2.0)
Avalonia Version 11.2.3
Steps to Reproduce:
Create a UserControl.
Place an empty ItemsRepeater on it, data binding is not necessary.
Create a window and display this UserControl in the new window as content.
Expected Behavior:
Closing the window should release all references to objects and remove the window from memory.
Actual Behavior:
References to the Window are held by the UserControl, references to the UserControl are held by ItemsRepeater, and references to ItemsRepeater are held by Layout. This causes memory leaks and prevents garbage collection. The specific event handlers involved are:
Additional context:
See attached sample project. Each time the "Yes Leak" button is pressed, objects will be created, but will never be deleted from memory.
In contrast, clicking the "No Leak" button creates objects, and closing the window marks objects for deletion.
The text was updated successfully, but these errors were encountered:
Add `WeakTypedEventHandler` for binding events with weak references.
Added weak event handlers to `ItemsRepeater` for `InvalidateMeasureForLayout` and `InvalidateArrangeForLayout`.
Fixed logical errors in check conditions.
Improve error message for `DataSource`.
Issue Description:
It seems that the ItemsRepeater component is causing memory leaks. After some investigation, I have determined that the leaks are due to lingering references to EventHandler in the OnLayoutChanged method.
Desktop/Platform:
Steps to Reproduce:
LeakTestItemsRepeater.zip
Expected Behavior:
Closing the window should release all references to objects and remove the window from memory.
Actual Behavior:
References to the
Window
are held by theUserControl
, references to theUserControl
are held byItemsRepeater
, and references toItemsRepeater
are held byLayout
. This causes memory leaks and prevents garbage collection. The specific event handlers involved are:Additional context:
See attached sample project. Each time the "Yes Leak" button is pressed, objects will be created, but will never be deleted from memory.
In contrast, clicking the "No Leak" button creates objects, and closing the window marks objects for deletion.
The text was updated successfully, but these errors were encountered: