Android内存限制

 先摘一段Google的官方文档:

        Mobile devices typically have constrained system resources. Android devices can have as little as 16MB of memory available to a single application. The Android Compatibility Definition Document (CDD), Section 3.7. Virtual Machine Compatibility gives the required minimum application memory for various screen sizes and densities. Applications should be optimized to perform under this minimum memory limit. However, keep in mind many devices are configured with higher limits.

        大致意思是说Android设备为每个app分配16MB的内存空间,虽然厂商会更改rom,定制更高的单个App内存空间,但是开发者应该依据最小的内存限制即16MB控制内存开销。

 

        Android设备屏幕大小不一,分辨率低至320*240,高至1280*720,对图片的需求也不同。如果在UI中需要加载一副大图片,明智的做法是先获取屏幕的分辨率,然后再决定加载图片的大小。在一款低分辨率的设备上加载高分辨率图片除了增加内存消耗,别无他用。因为设备最大能展示的清晰度为本身的屏幕分辨率。所以,如果一个不需要放大图片的控件需要加载图片,最大只需要加载该控件本身宽高的图片即可。

       Given that you are working with limited memory, ideally you only want to load a lower resolution version in memory. The lower resolution version should match the size of the UI component that displays it. An image with a higher resolution does not provide any visible benefit, but still takes up precious memory and incurs additional performance overhead due to additional on the fly scaling.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值