So I get this:
'01-01 20:37:34.859: E/dalvikvm-heap(19921): Out of memory on a 6471856-byte allocation.'
When trying to assign a bunch of variables to memory. I'm assigning 24 variables like these:
mElements.add(new ShopElement(getResources(),R.drawable.shop_starter, b1X , b1Y,true,1,"red",true,5,checkLocked(0)));
And one of these:
bNumbers = new Bitmap[] {Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h0)
, 65,65, true),
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h1)
, 65,65, true),
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h2)
, 65,65, true),
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h3)
, 65,65, true),
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h4)
,65,65,true),
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h5)
, 65,65, true),
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h6)
, 65,65, true),
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h7)
, 65,65, true),
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h8)
, 65,65, true),
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.h9)
, 65,65, true),
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.time)
, 50,50, true)};
But before I can get through #16 of the 24 elements I'm created, it crashes on certain phones.
I have a Galaxy S2 and it runs fine, but on the S3 and other phones it crashes.
I will be happy to provide more information upon request.
I've searched this error before, tried to apply solutions, and looked through the "Displaying Bitmaps Efficiently" thing, but nothing seems to help.
What spins my head is that it works on the S2, but not the S3. Shouldn't the S3 exceed the S2 in every way?
I am using a global BitmapFactory.Options to draw all my bitmaps I set the options as follows:
Global.opts = new BitmapFactory.Options();
Global.opts.inDither=false;
Global.opts.inPurgeable=true;
Global.opts.inInputShareable=true;
Global.opts.inTempStorage=new byte[16 * 1024];