安卓:我的应用程序使用多少内存? [英] Android: How much memory is my app using?
本文介绍了安卓:我的应用程序使用多少内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
内存似乎是一个很大的话题,我不能找到具体的答案。 我有多少是堆中提供的答案,我知道我应该使用多少。我需要的答案如何code以编程方式确定我的应用程序使用多少内存堆?又有多少总内存我使用?
Memory seems to be a big topic and I cant find the specific answer. I've got the answers on how much is available in the heap and I know how much should I use. I need the answer how to code to programatically determine how much memory is my app using of the heap? And how much total memory am I using?
推荐答案
本作品:
Debug.MemoryInfo memoryInfo = new Debug.MemoryInfo();
Debug.getMemoryInfo(memoryInfo);
String memMessage = String.format("App Memory: Pss=%.2f MB\nPrivate=%.2f MB\nShared=%.2f MB",
memoryInfo.getTotalPss() / 1024.0,
memoryInfo.getTotalPrivateDirty() / 1024.0,
memoryInfo.getTotalSharedDirty() / 1024.0);
Toast.makeText(this,memMessage,Toast.LENGTH_LONG).show();
Log.i("log_tag", memMessage);
这篇关于安卓:我的应用程序使用多少内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文