android memory 优化
First,GC will not recycle the memory at once you called. Here are some advice from android developer website:
-
Do not keep long-lived references to a context-activity (a reference to an activity should have the same life cycle as the activity itself)
-
Try using the context-application instead of a context-activity
-
Avoid non-static inner classes in an activity if you don't control their life cycle, use a static inner class and make a weak reference to the activity inside. The solution to this issue is to use a static inner class with a WeakReference to the outer class, as done in ViewRoot and its W inner class for instance
-
A garbage collector is not an insurance against memory leaks
Second, try to use BitmapFactory.options when you do not very care the quality of the bitmap.
Third, use try catch to process the OutOfMemory exception in catch block.
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer