androidx / constraintlayout

ConstraintLayout is an Android layout component which allows you to position and size widgets in a flexible way
Apache License 2.0
1.06k stars 177 forks source link

Memory leaks for Carousel.java when Views are getting recycled, e.g. in RecyclerView #715

Open FloriJann opened 1 year ago

FloriJann commented 1 year ago

As far as I can tell, the internal list mList, which holds references to the child views of carousel, is causing this issue.

Whenever the onAttachedToWindow function of Carousel.java gets called, new items will be added to the list mList. As a result, the internal data and the displayed data get out of sync, which results in the wrong data being displayed within the carousel.

In addition mList grows with every call of onAttachedToWindow and never gets cleared.

A simple solution could be to just clear the internal list when onDetachedFromWindow gets called.