Google 官方的一些内存管理文档

本文介绍了Android应用程序的内存管理策略,包括使用paging和mmapping技术、共享内存机制、内存检查方法以及如何通过优化来减少内存使用。同时提供了调查RAM使用情况的工具和技术,并探讨了避免内存泄漏的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Managing Your App's Memory
Android 使用paging,mmapping, 不使用swap
共享内存(Share Memory)
   Zygote进程加载的系统资源,如Theme
   Static data,如Dalvik code、app resources 、.so文件
   匿名共享内存子系统Ashmem(Anonymous Shared Memory)
     如:window surfaces use shared memory between the app and screen compositor, and cursor buffers use shared memory between the content provider and client

检查可用内存  getMemoryClass()


保守使用并尽快结束服务IntentService
UI不可见时,及时释放内存
    onTrimMemory() (API level 14)与 onStop() 的区别
      Keep in mind that an increase in bitmap resolution results in a corresponding (increase2) in memory needed, because both the X and Y dimensions increase.
使用Android系统提供的一些新的实现
    SparseArray, SparseBooleanArray, and LongSparseArray比HashMap更有效率,占用的内存更少


Investigating Your RAM Usage
adb shell dumpsys meminfo <package_name>
为更容易发现内存泄漏,要制造内存压力
     在不同使用状态下,多次转屏
     应用间切换
     使用Monkey


MAT(Memory Analyzer Tool)内存分析工具

http://my.eoe.cn/futurexiong/archive/1299.html



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值