开发者

Strange "Out of Memory" Error

开发者 https://www.devze.com 2023-02-05 14:46 出处:网络
My app is r开发者_开发技巧unning properly on some Android devices but on some devices it\'s giving an out of memory error.

My app is r开发者_开发技巧unning properly on some Android devices but on some devices it's giving an out of memory error.

Here is the LogCat log:

http://logcat.miui-dev.com/147001

What this Activity does is load Bitmaps, and display those Bitmaps through onDraw().

What would cause this error?

what am doing ?

Am just maping all images in a method image

_bitmapCache.put(R.drawable.gb2, BitmapFactory.decodeResource( getResources(), R.drawable.gb2));

and when a constructor is called i call that method , while using image i just use

canvas.drawBitmap(_bitmapCache.get(R.drawable.level1c1), 0, 0, null);

to craw the image


It looks like you are requesting an 18 meg image. You need to scale your images way down. Each app is only allowed 16-24megs of heap space. I'd have to see more of your code to make further suggestions, but an 18 meg image is really too large and the ImageView doesn't do the best job of automatically scaling the images, so you usually have to do the scaling before display in my experience.


You have to specify in the Options of BitmapFactory a inSampleSize that will allow to directly load a scaled down version of the Bitmap.

0

精彩评论

暂无评论...
验证码 换一张
取 消