有关于android:largeHeap 的一些观点
2016-08-09 14:42
459 查看
有关于android:largeHeap 的一些观点
来源于:What are advantages of setting largeHeap to true?先说结论:android:largeHeap=”true”可以为你的程序提供更大的内存,如果你想让你的程序更少遇到”OOM”的问题的话,可以考虑用这个方法来直接偷懒。
下面是Google对于不建议使用android:largeHeap=”true”的描述:
However, the ability to request a large heap is intended only for a small set of apps that can justify the need to consume more RAM (such as a large photo editing app). Never request a large heap simply because you’ve run out of memory and you need a quick fix—you should use it only when you know exactly where all your memory is being allocated and why it must be retained. Yet, even when you’re confident your app can justify the large heap, you should avoid requesting it to whatever extent possible. Using the extra memory will increasingly be to the detriment of the overall user experience because garbage collection will take longer and system performance may be slower when task switching or performing other common operations.
对于开发者来说,最重要的不是说程序的功能多完善,多厉害,而是程序的维护性和稳定性。
所以我们需要的是掌控自己开发的程序,比如说哪里分配了大的内存而且它为什么要留着而不清除。
如果使用了过多的内存,对于用户来说也并不好:
你可能会丧失一些帧,会导致一些视觉残留。 更大的内存导致GC花费的时间会增加,通常来说,GC暂停时间大约是5ms,可能你觉得毫秒而已,没什么大不了的。但是Android设备每16ms就会刷新一次屏幕,这么以来,更长的GC时间将让你的帧处理时间超过16ms的界限,这就可能导致一个视觉残留。
并且在切换APP的时候会变得更慢。因为使用了过多的内存,那么如果在后台的时候,就更可能会被系统回收。那么当用户从其他的应用切回你的应用的时候,会花费更长的时间。
相关文章推荐
- 关于android:largeHeap的学习
- 关于软件工程的一些观点
- 关于Android的一些体验
- 一些关于Android的代码地址
- 关于android中使用很多大图片的一些做法
- Android自用-----Android中一些关于Activity的技巧
- 关于Peercast一些观点的更新
- 关于界面设计的一些观点
- [Android 博客]收集一些不错的,关于android的IT Blog,互相学习!
- 关于Android开发过程中,createImage的一些总结。
- Android-一些关于代码优化的事儿---摘录
- 关于软件工程的一些观点
- 俺网站Android及Ophone开发,全系列上手资料,关于环境搭建遇见的一些问题,包1天能上手。
- 关于对android移植的一些想法
- [Android 博客]收集一些不错的,关于android的IT Blog,互相学习!
- 关于互联网的一些观点想法
- 关于android游戏开发的一些基础和个人经验
- 关于Android中传递数据的一些讨论
- 关于Android下WIFI移植的一些指导文章
- 关于架构设计的一些观点