First,GC will not recycle the memory at once you called. Here are some advice from android developer website:

  1. 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)

  2. Try using the context-application instead of a context-activity

  3. 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

  4. 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.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android init进程分析 基本流程
  2. Android 的缓存机制 Lrucache
  3. Android 高仿微信头像截取 打造不一样的
  4. 学习android心里旅程
  5. Android(安卓)仿携程活动列表边框布局
  6. 实现类似android:clipChildren="false"的
  7. android中自定义Toast方法详解(一)
  8. 谁告诉你鸿蒙(HarmonyOS)不能在macOS下玩,一
  9. Android音频系统之音量控制详解(Android 5
  10. android ICS横竖屏定制及利用G-Sensor转