导航:首页 > 操作系统 > 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地址相关的资料

热点内容
华为手表运动健康app怎么弄 浏览:1000
ftp文件夹形式 浏览:666
房本抵押银行没有解压 浏览:535
用纸做解压魔术 浏览:484
服务器中运行的脚本如何测试 浏览:373
手机主题包时钟文件夹 浏览:423
怎么在app上退订短号业务 浏览:978
解压迫及法老 浏览:58
pdf横竖 浏览:137
5800计算机程序和编程 浏览:29
网上报修php源码 浏览:897
魔兽宏命令老是语言提示 浏览:971
办公文件夹大全 浏览:471
单片机闪烁灯虚拟线路图 浏览:72
App显示别的国家怎么更改 浏览:154
幻塔官方服务器叫什么 浏览:196
android自定义进度框 浏览:506
linux自动联网 浏览:492
keil编写的程序怎么不能编译呢 浏览:562
ipadair2能编程吗 浏览:358