xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] CollectionView leaks when binding #9288

Closed hulluP closed 1 year ago

hulluP commented 4 years ago

Description

When binding Collection view to a ObservableCollection the items of the collection stay in memory. See profiling see screenshot Even removing the binding when the view disappears does not solve the issue. When the binding is not added the code does not introduce the memleak.

Steps to Reproduce

  1. clone the repo https://github.com/hulluP/CollectionViewTest/tree/MemLeakIssue branch memleak
  2. open profiler
  3. when app has started click on button "click" to launch the view with the collection view
  4. click on back button to close view
  5. repeat steps 3 and 4 multiple times
  6. the profiler will show multiple items of the collectionViewTestX, ViewImage ....

Expected Behavior

when view closes all controls release their bindings and the objects can be collected by the GC

Actual Behavior

when CollectionView gets popped it does not release the binding

Basic Information

Screenshots

Screenshot 2020-01-23 at 05 41 43

Reproduction Link

https://github.com/hulluP/CollectionViewTest/tree/MemLeakIssue

Workaround

PureWeen commented 4 years ago

Possibly related

https://github.com/xamarin/Xamarin.Forms/issues/11819