Android-Image-Slider icon indicating copy to clipboard operation
Android-Image-Slider copied to clipboard

Memory Leakage

Open rommansabbir opened this issue 4 years ago • 4 comments

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?

image

rommansabbir avatar Feb 13 '21 14:02 rommansabbir

i have same problem, this library cause too big memory leak... have you solved the issue?

superdiazzz avatar Feb 22 '21 04:02 superdiazzz

Didn't find any optimal solution, but I'm clearing the layout binding (Data Binding) reference onStop() method.

rommansabbir avatar Mar 06 '21 08:03 rommansabbir

in my case i cleared the data of the list image with list.clear() and called the function on onStop(), and it worked

rivaldofez avatar Jul 16 '21 20:07 rivaldofez

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

belloabraham avatar Jan 20 '22 08:01 belloabraham