30、内存优化之内存泄漏记录

来源:互联网 发布:小说改编的网络剧 编辑:程序博客网 时间:2024/05/09 18:09

1、fragment 单例使用问题:

  private static DownLoadedFragment instance;    private Context mContext;    public DownLoadedFragment() {    }    public static DownLoadedFragment getInstance() {        if (instance == null) {            instance = new DownLoadedFragment();        }        return instance;    }

修改 

public static DownLoadedFragment getInstance() {        DownLoadedFragment instance = new DownLoadedFragment();        return instance;    }

马蛋  ,fragment 使用单例的模式创建,也是醉了 !!!  打死也不承认是我写的代码

2、单例方法 引用 context ,






处理过后


这个 没话说,自己找的工具类,没有仔细审查!!!  怪我咯。。。

3、使用timer  最后没有关闭 导致内存泄漏
关闭忘记密码页面,由于 timer没有cancle 导致,


修改代码 关闭 页面后 ,当前类得到释放。



需要在onDes