2

I want to load an image on android

background = BitmapFactory.decodeResource(getResources(),R.drawable.hangmanbegin);    
background =  Bitmap.createScaledBitmap(background,screenx,screeny,false);

The image is 800*1280 pixels , so if I'm correct it should use arround 3MB of memory space? But my heap grows from 15MB to 29MB just at that phase , so no window or context leaking?

How is this explained? en what can you do about it?

Thnx in advance!

0

1 Answer 1

3

Bitmaps take up a lot of memory, especially for rich images like photographs. For example, the camera on the Galaxy Nexus takes photos up to 2592x1936 pixels (5 megapixels). If the bitmap configuration used is ARGB_8888 (the default from the Android 2.3 onward) then loading this image into memory takes about 19MB of memory (2592*1936*4 bytes), immediately exhausting the per-app limit on some devices.

from http://developer.android.com/training/displaying-bitmaps/index.html

credit and below it a way to approach a fix https://stackoverflow.com/a/10127787/643500

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.