ImageAdapter和ListView(java.lang.OutOfMemoryError:位图大小超过VM预算) [英] ImageAdapter and ListView (java.lang.OutOfMemoryError: bitmap size exceeds VM budget)

查看:150
本文介绍了ImageAdapter和ListView(java.lang.OutOfMemoryError:位图大小超过VM预算)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ListView控件来显示我通过ImageAdapter类提供的图像。 它的伟大工程我的设备上(和我测试了许多其他设备),但不知何故,当我使用模拟器,我长期pressing上/下按钮 - 我发现了一个内存不足10-15秒后错误。

I'm using ListView to display images which I provide through an ImageAdapter class. it works great on my device (and on many other devices which I tested it on), but somehow when I'm using the emulator and I'm long-pressing the up/down button - I'm getting an outOfMemory error after 10-15 seconds.

我试图清除缓存,取消缓存,等等 - 没有任何帮助

I tried clearing cache, canceling cache, etc. - nothing helped.

我知道这崩溃是pretty的罕见的(我不能复制它的任何真正的设备),但我可以在DDMS看到,全球契约中解脱出来的规模越来越大时,长期preSS和我无法找到一个方法来清除它们。

I know this crash is pretty rare (i couldn't reproduced it on any "real" device), but I can see on DDMS that "GC freed" are getting bigger during that long press and I can't find a way to clear them.

任何帮助将AP preciated,TNX。

Any help will be appreciated, Tnx.

推荐答案

您应该取消code与inSampleSize选项,以减少内存消耗。 <一href="http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue/823966#823966">http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue/823966#823966

You should decode with inSampleSize option to reduce memory consumption. http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue/823966#823966

另一种选择inJustDe codeBounds可以帮助你找到正确的inSampleSize值的http://groups.google.com/group/android-developers/browse_thread/thread/bd858a63563a6d4a

Another option inJustDecodeBounds can help you to find correct inSampleSize value http://groups.google.com/group/android-developers/browse_thread/thread/bd858a63563a6d4a

您也应该考虑使用inPurgeable选项<一href="http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inPurgeable" rel="nofollow">http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inPurgeable.它可以让系统来释放你的记忆,以避免内存不足。

You should also consider using inPurgeable option http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inPurgeable. It allows system to free your memory to avoid OutOfMemory.

这篇关于ImageAdapter和ListView(java.lang.OutOfMemoryError:位图大小超过VM预算)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆