Android-Image-Slider
Android-Image-Slider copied to clipboard
Memory Leakage
I have an activity & several fragments. I have implemented this one of my fragment. So when I'm trying to open another activity, detects memory leakage.
How to avoid this leakage?

i have same problem, this library cause too big memory leak... have you solved the issue?
Didn't find any optimal solution, but I'm clearing the layout binding (Data Binding) reference onStop() method.
in my case i cleared the data of the list image with list.clear() and called the function on onStop(), and it worked
The leak is caused as a result of a looper running in background that invokes a callback to loop the SliderView every 2 seconds on line 648 of the SliderView class, this functionality will be active if you set startautocle = true or call startAutoCycle() on the sliderView. The problem is that when the SliderView gets destroyed on the UI thread, the loopers which is running on the background thread will not be destroyed along and will continue to invoke the callback to loop the SliderView on the UI thread (that is destroyed) preventing the garbage collector from clearing the SliderView in the memory.
TLDR; Cause of leak: startAutoCycle() was called on slider view either by you or a default attribute on SliderView Solution: call stopAutoCycle() either in Fragment onDestroyView or in Activity onDestroy and this depends on where you are using SliderView if in a Fragment or an Activity. If you are using SliderView in a fragment, also remember to set the fragment's view to null in onDestroyView after you call stoptAutoCycle() on SliderView e.g binding.sliderView.stopAutoCycle() binding = null