android之Bitmap内存溢出

来源:互联网 发布:淘宝图文详情页 编辑:程序博客网 时间:2024/04/29 12:53

最近调试由Bitmap加载图片引起的OOM(out of memory),在网上搜索了好多解决办法,大部分都是加载图片时做内存优化,http://www.apkbus.com/android-2386-1-1.html

在android3.0以后,Bitmap的内存全部在java heap中,使用将Bitmap的对象置null或recycle()已经没什么用了,如果使用setBackgroundDrawable(pic),需要对应使用setBackgroundDrawable(null),然后System.gc()去释放内存,同理setImageDrawable(pic),使用setImageDrawable(null)。

www.zhihu.com/question/36592051


0 0
原创粉丝点击