【发布时间】:2011-02-25 01:26:58
【问题描述】:
可能重复:
Android: Strange out of memory issue while loading an image to a Bitmap object
我正在从 Url 下载图像并显示它们。在下载时它给
out of memory error : bitmap size exceeds VM budget。
我正在使用可绘制的。代码如下:
HttpClient httpclient= new DefaultHttpClient();
HttpResponse response=(HttpResponse)httpclient.execute(httpRequest);
HttpEntity entity= response.getEntity();
BufferedHttpEntity bufHttpEntity=new BufferedHttpEntity(entity);
InputStream instream = bufHttpEntity.getContent();
Bitmap bm = BitmapFactory.decodeStream(instream);
Bitmap useThisBitmap =
Bitmap.createScaledBitmap(bm,bm.getWidth(),bm.getHeight(), true);
bm.recycle();
BitmapDrawable bt= new BitmapDrawable(useThisBitmap);
System.gc();
这里是错误:
`05-28 14:55:47.251: ERROR/AndroidRuntime(4188):
java.lang.OutOfMemoryError: bitmap size exceeds VM budget`
【问题讨论】:
-
如果图像真的很大,这个解决方案应该可以帮助stackoverflow.com/questions/477572/…
-
嗨,马塞洛·坎托斯!!! ..图像的高度和宽度= 320x320
-
找出您可以通过多少种方式获取图像,这样您就不会发现内存问题
-
感谢 OM The Eternity,,, 我试过了...但主要问题是 VM...
-
我知道我来晚了,但是如果生成图像并且在创建它时 (
img = Bitmap.createBitmap(size.x, size.y, Bitmap.Config.ARGB_8888);) 会崩溃怎么办?
标签: android bitmap out-of-memory