导航:首页 > 操作系统 > androidmat地址

androidmat地址

发布时间:2023-08-11 17:52:42

android用MAT检测内存泄漏问题。。

Eclipse 有个插件工具MAT(Memory Analyzer Tool)可以帮助定位内存泄漏的对象。
安装MAT Update site: http://archive.eclipse.org/mat/1.1/update-site/
用DDMS工具Dump出问题App的.hprof文件 比如com.world.test2.hprof Dump之前最好先运行一下GC "Cause GC" , 确保mp出来的是还不能回收的对象等。
用SDK tools下工具hprof-conv.exe 做转换 hprof-conv com.world.test2.hprof appleak.hprof
用Eclipse “Open Head Dump”打开新转换的.hprof 文件--appleak.hprof 查看图形化界面,一个一个检查怀疑的点。
总结: MAT tool不会直接告诉你哪里内存泄漏,但是会列出怀疑的对象,需要你仔细检查这些对象为什么没有被释放掉。
下面是测试code, 在Android 4.2.2上测试过。 1. 此种情况可以引起Activity无法回收的情况,因为直接用类似private static Activity a0引用创建的Activity,导致Activity无法回收。 2. 此种情况没有引起Activity 无法回收的情况。 按理说这种情况应该也会导致静态Drawable 锁定Activity, 引用关系mBackground1-->Button-->Activity. 待分析
public class MainActivity extends Activity implements Button.OnClickListener{

final private static String TAG = "MainActivity";

private static Drawable mBackground1;

private static Drawable mBackground2;

private static Drawable mBackground3;

private static Drawable mBackground4;

private static Activity a0 ;

private static Activity a1 ;

private static Activity a2 ;

private static Activity a3 ;

private static Activity a4 ;

/*

* Shutdown intent

*/

private final String INTENT_ACTION_REQUEST_SHUTDOWN =

"android.intent.action.ACTION_REQUEST_SHUTDOWN";

@Override

public void onCreate(Bundle savedInstanceState) {

Log.v(TAG, "onCreate Activity="+this);

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

//1

if(false){

if(a0 == null){

a0 = this;

Log.v(TAG, "onCreate Activity a0="+a0);

}

else if(a1 == null){

a1 = this;

Log.v(TAG, "onCreate Activity a1="+a1);

}

else if(a2 == null){

a2 = this;

Log.v(TAG, "onCreate Activity a2="+a2);

}

else if(a3 == null){

a3 = this;

Log.v(TAG, "onCreate Activity a3="+a3);

}

else if(a4 == null){

a4 = this;

Log.v(TAG, "onCreate Activity a4="+a4);

}

}

//set up button listener

Button myButton = (Button)findViewById(R.id.button_poweroff);

myButton.setOnClickListener(this);

myButton = (Button)findViewById(R.id.button_reboot);

myButton.setOnClickListener(this);

//2

if (mBackground1 == null) {

Log.v(TAG, "onCreate mBackground1");

mBackground1 = getResources().getDrawable(R.drawable.adbroot_004);

myButton.setBackgroundDrawable(mBackground1);
}

else if(mBackground2 == null){

Log.v(TAG, "onCreate mBackground2");

mBackground2 = getResources().getDrawable(R.drawable.test002);

myButton.setBackgroundDrawable(mBackground2);

}

else if(mBackground3 == null){

Log.v(TAG, "onCreate mBackground3");

mBackground3 = getResources().getDrawable(R.drawable.test003);

myButton.setBackgroundDrawable(mBackground3);

}

else if(mBackground4 == null){

Log.v(TAG, "onCreate mBackground4");

mBackground4 = getResources().getDrawable(R.drawable.adbroot_003);

myButton.setBackgroundDrawable(mBackground4);

}

}

❷ android mat 什么意思

简单的说就是android的一个内存分析工具。帮助优化你的app。

MAT(Memory Analyzer Tool),一个内存分析工具,是一个快速、功能丰富的JAVA heap分析工具,它可以帮助我们查找内存泄漏和减少内存消耗。使用内存分析工具从众多的对象中进行分析,快速的计算出在内存中对象的占用大小,看看是谁阻止了垃圾收集器的回收工作,并可以通过报表直观的查看到可能造成这种结果的对象。

你可以把它集成到android studio或者Eclipse里面。然后使用它分析你的app。具体的使用方法你可以网上搜索。

阅读全文

与androidmat地址相关的资料

热点内容
算法对于中学生的影响 浏览:787
linux如何看编译器c库 浏览:430
dnf为什么选择服务器没有了 浏览:866
马鞍山加密软件有哪些 浏览:173
linux命令用不了 浏览:109
单片机不同输入输出口 浏览:965
单击右键没有压缩 浏览:729
荣耀魔方2方舟编译器 浏览:431
服务器如何访问局域网电脑 浏览:754
倒角命令快捷键 浏览:28
梯形图编程abs是什么意思 浏览:834
狂浪小说app在哪里下载 浏览:537
python爬虫页面跳转 浏览:534
led数码管编译器 浏览:245
该站点内容加密如何浏览 浏览:933
androidwebview实例 浏览:171
dns服务器不存在怎么解决 浏览:96
谷歌服务器错误怎么弄 浏览:543
中国银行公告在app哪里 浏览:955
计件单价算法 浏览:831