现在我们换一种更清晰方便的方式:LeakCanary https://github.com/square/leakcanary

首先将LeakCanary绑在我们的app上 
build.gradle

dependencies{
dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
}
public class SunApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Global.mContext = SunApplication.this.getApplicationContext();
initializeLeakDetection();
} private void initializeLeakDetection() {
if (BuildConfig.DEBUG) {
LeakCanary.install(this);
}
}
}

Manifest 添加权限WRITE_EXTERNAL_STORAGE、不然会发生错误、如下代码 
android 6.0以上另外获取权限、详情请见我的博文 Android 6.0 最简单的权限获取方法 RxPermition EasyPermition

  <!--Required by Debug.startMethodTracing() -->
<!--LeakCanary need this Unable to resume activity
{com.rvitemtouch.sun.sundagger2application/com.squareup.leakcanary.internal.DisplayLeakActivity}:
java.lang.UnsupportedOperationException: Could not create leak directory
/storage/emulated//Download/leakcanary-com.rvitemtouch.sun.sundagger2application-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

安装好了、运行app、继续将之前写的(Android AndroidStudio MAT LeakCanary 内存分析之 AndroidStudio 内存泄漏分析 Memory Monitor

Activity反复翻转屏幕、导致内存泄漏

出现内存泄漏提示

Leaks 会伴随我们的app一块install、那么打开leaks、等待一会

找到我们定位的泄漏 打开


就能看出详细的链式结构、上面写的很明白了、正如之前我们所料 
是Memory..Activity的引用被Runnable占用了

最新文章

  1. nodejs pm2部署配置
  2. cygwin和mingw的区别
  3. C/C++ 记录时间
  4. 【dubbo】dubbo项目基本结构及provider构建
  5. Android控件颜色设置为透明
  6. IOS第八天(2:UITableViewController团购,点击底部,xib加载更多, 代理模式)
  7. easyui 进度条
  8. 定时组件quartz系列&lt;二&gt;quartz的原理
  9. UVa 10617 Again Palindromes / 记忆化搜索
  10. IOS 特定于设备的开发:使用加速器启动屏幕上的对象
  11. mybatis配置文件xxxx.xml中缺失返回类型的后果A query was run and no Result Maps were found
  12. python [1:3]
  13. 多线程(3)ThreadPool
  14. white-space:pre-wrap和word-break:break-all;
  15. WebClient图片下载
  16. 【Unity】项目工程源码
  17. UI5-学习篇-5-SAP创建OData服务-Structure
  18. Scala学习网址
  19. Oracle存储过程入参传入List集合的小例子
  20. 初始化 Flask 虚拟环境 命令

热门文章

  1. 基于 Web 的 Go 语言 IDE - Wide 1.2.0 发布!
  2. hibernate generator id
  3. C++中全局变量的声明和定义
  4. 《三》build 快速创建模块
  5. oracle之dbms_output
  6. 【Linux系统引导过程】
  7. jQuery对checkbox选中和取消选中操作
  8. 【Codeforces Round #460 (Div. 2) D】Substring
  9. UML类图中的几种关系总结
  10. POJ 2104 K-th Number 静态主席树(裸