`
大头K
  • 浏览: 183044 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Universal-Image-Loader 内存占用

阅读更多
前言:之前项目一直使用Universal-Image-Loader图片加载框架,毕竟算是github上最火的图片加载框架之一,而且用到该框架的比较大的应用也不少,所以挺放心的。

这两天,项目经理发现项目加载图片时内存会爆增,而且有时还报OOM,(一个坑爹手机,其实是不是这个框架报错还有待考察)之后就一直找原因,官方上面也有介绍,以下是原文:

If you often got OutOfMemoryError in your app using Universal Image Loader then try next (all of them or several):

Reduce thread pool size in configuration (.threadPoolSize(...)). 1 - 5 is recommended.
Use .bitmapConfig(Bitmap.Config.RGB_565) in display options. Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888.
Use .memoryCache(new WeakMemoryCache()) in configuration or disable caching in memory at all in display options (don't call .cacheInMemory()).
Use .imageScaleType(ImageScaleType.IN_SAMPLE_INT) in display options. Or try .imageScaleType(ImageScaleType.EXACTLY).


介绍了一些方法减少内存使用,比如修改配置信息、显示选项等。加上去以后,内存的使用好像有一点变化,不过也不大明显。另外还设置了支持largeHeap,OOM也不再报。

其实也测试过一些配置比较低的手机上,根本不会出现OOM,内存也不会占用高,并且查看很流畅。

怎么说呢,其实加载图片内存变大,这不都很正常吗?说句心里话吧,其实内存占用跟性能是同时存在,内存换性能,换来体验。内存高点也正常,只要不报OOM就可以了,JVM 的 GC机制还没有到那么垃圾的地步
(注:那坑爹手机配置不低)
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics