Ilario
Ilario

Reputation: 6079

Out of memory on a 11223056-byte allocation

I searched about this problem, and I read that most of the time is related to the use Bitmap.

But in my case i don't use Bitmap,

I have a GridView, which on click on an item goes to the detail page. In the detail page, i set a background image random in this way:

int[] imageList = new int[]{R.drawable.one, R.drawable.two, R.drawable.three, R.drawable.four, R.drawable.five,
                            R.drawable.six, R.drawable.seven, R.drawable.eight, R.drawable.nine};

...

@Override
protected void onStart() {
  super.onStart();

  Random ran = new Random();
  int imageInt = ran.nextInt(8)+1;

  image.setImageResource(imageList[imageInt]);

}

the problem appears each about 4 times when I go into the detail page, not always, but approximately every 4 times

the screen comes black for some seconds and after i have this error:

Channel is unrecoverably broken and will be disposed!

but the app does not crash, only the black screen for a few seconds and then returns the app...

all images are the same size, and are about 15kb

thanks everybody

Upvotes: 2

Views: 703

Answers (2)

Marcel Tricolici
Marcel Tricolici

Reputation: 440

Adjust your manifest file. Add android:largeHeap="true" to the application tag.

Upvotes: 3

koljaTM
koljaTM

Reputation: 10262

If it is every one in 4 starts it sounds like one or two of your random images are giving you trouble. I would recommend to lgo which image is tried to set and if you find out a specific image is the culprit try to find out what is the matter with that file. Maybe you forgot to scale down one of the graphics?

Upvotes: 0

Related Questions