【发布时间】:2025-12-31 15:15:13
【问题描述】:
有没有人解决daimajia AndroidImageSlider库内存泄漏?
我在我的项目中使用它,它完美地满足了所有需求。
唯一的麻烦是片段重新创建后发生的内存泄漏,
这个“滑动画廊”的旧实例保留在内存中,并导致 OutOfMemory。
我尝试在 SliderLayout.java 中覆盖 onDetachedFromWindow 方法
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
if(mCycleTimer != null) mCycleTimer.cancel();
if(mCycleTask != null) mCycleTask.cancel();
if(mResumingTask != null) mResumingTask.cancel();
if(mResumingTimer != null) mResumingTimer.cancel();
mh.removeCallbacksAndMessages(null);
}
如此处所述:https://github.com/daimajia/AndroidImageSlider/issues/122
当然我也在onStop()方法中调用removeAllSliders()和stopAutoCycle()
但不幸的是它没有帮助
感谢任何建议
【问题讨论】:
标签: android memory-leaks