【内存泄漏Bug】animation未释放

问题描述

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

问题分析

这个activity的特性是

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

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

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

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

问题解决

  1. 优化stop的实现为:

    /**

    * 停止播放

    */

    public synchronized void stop() {

    mShouldRun = false;

    mHandler.removeCallbacksAndMessages(null);

    }

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

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

相关推荐
f***241113 小时前
Bug悬案:技术侦探的破案指南
算法·bug
前端大波15 小时前
avue-crud 操作列透明 bug
bug
hui函数2 天前
Python系列Bug修复|如何解决 pip install 安装报错 invalid command ‘bdist_wheel’(缺少 wheel)问题
python·bug·pip
hui函数2 天前
Python系列Bug修复|如何解决 pip install -r requirements.txt 私有索引未设为 trusted-host 导致拒绝 问题
python·bug·pip
hui函数2 天前
Python系列Bug修复|如何解决 pip install 安装报错 Backend ‘setuptools.build_meta’ 不可用 问题
python·bug·pip
hui函数2 天前
Python系列Bug修复|如何解决 pip install -r requirements.txt 私有仓库认证失败 401 Unauthorized 问题
python·bug·pip
hui函数2 天前
Python系列Bug修复|如何解决 pip install -r requirements.txt 子目录可编辑安装缺少 pyproject.toml 问题
python·bug·pip
啊湘3 天前
VSCODE英文界面切换为中文(适用CURSOR等使用)
ide·vscode·编辑器·bug·cursor
hui函数3 天前
Python系列Bug修复|如何解决 pip install -e . 安装报错 “后端不支持可编辑安装(PEP 660)” 问题
python·bug·pip
一条咸鱼_SaltyFish3 天前
[Day16] Bug 排查记录:若依框架二次开发中的经验与教训 contract-security-ruoyi
java·开发语言·经验分享·微服务·架构·bug·开源软件