daimajia / daimajia/AndroidImageSlider

can't release memory automatically

Open
#122 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.6k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Hi, I found the problem, I think you should override the onDetachedFromWindow() method, because when current SliderLayout instance detach from the window, you should stop the Timer and TimerTask and removeCallbacksAndMessages, or the Context instance of the relevant activity will can't be release, and this will lead to the memory leaks. When I add the code below to the SliderLayout.java, the leaks problem is sovled.
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
CustomLog.debug(LOG_TAG, "onDetachedFromWindow() ***");
if(mCycleTimer != null) mCycleTimer.cancel();
if(mCycleTask != null) mCycleTask.cancel();
if(mResumingTask != null) mResumingTask.cancel();
if(mResumingTimer != null) mResumingTimer.cancel();
mh.removeCallbacksAndMessages(null);
}
But actually, I can't surely if this is what the problem is?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.