【内存泄漏Bug】animation未释放

问题描述

一个页面做了动画特效,这个页面有可能跳转到其他页面,并长时间不返回,该页面此时已经不活跃了,该页面的对象为无用对象,存在内存泄漏风险

问题分析

这个activity的特性是

  1. 有可能跳转到其他页面

  2. 有可能从其他页面跳转回来

  3. 点击back按钮,并不会杀死当前页面

页面不再处于前台的时候,未将动画暂停,释放动画资源

问题解决

  1. 优化stop的实现为:

    /**

    * 停止播放

    */

    public synchronized void stop() {

    mShouldRun = false;

    mHandler.removeCallbacksAndMessages(null);

    }

  2. 在onPause、onResume做动画的停止、恢复处理,避免重复创建动画;

  3. 在onDestory做动画的销毁处理,避免无法gc

相关推荐
phantom_1111 天前
Cursor 分析 bug 记录
bug·cursor
Direction_Wind2 天前
Flinksql bug: Heartbeat of TaskManager with id container_XXX timed out.
大数据·flink·bug
AIBigModel5 天前
智能情趣设备、爆 bug:可被远程操控。。。
网络·安全·bug
Direction_Wind5 天前
flinksql bug: Received resultset tuples, but no field str
bug
远瞻。5 天前
【bug】diff-gaussian-rasterization Windows下编译 bug 解决
windows·bug
中草药z5 天前
【测试】Bug+设计测试用例
功能测试·测试工具·测试用例·bug·压力测试·测试
我又来搬代码了5 天前
【Android】【bug】Json解析错误Expected BEGIN_OBJECT but was STRING...
android·json·bug
葵野寺6 天前
【软件测试】BUG篇 — 详解
bug·测试
青青子衿越8 天前
微信小程序右上角分享页面找不到路径bug
微信小程序·小程序·bug
刘火锅9 天前
Bug 记录:SecureRandom.getInstanceStrong()导致验证码获取阻塞
spring boot·spring·spring cloud·bug