BitmapFactory.decodeResource e inexplicável Out of Memory

Recebo um estranho erro de Memória incompleta, que decodifica um recurso de image desenhável 960x926px jpg, alocando o byte 3555856. A image é colocada apenas em drawable-xxhdpi (3x) e estou usando um dispositivo hdpi (1.5x). Duas perguntas:

Alguém pode me explicair?

NOTA: a questão é sobre por que obter um OOM paira 3.5MB de alocação enquanto possui 22.5MB de memory livre (veja o log)

03-18 17: 30: 15.050 32750-32750 /? D / dalvikvm: GC_FOR_ALLOC liberado 10809K, 49% livre 23735K / 46087K, pausado 89ms, total 89ms

03-18 17: 30: 15.050 32750-32750 /? I / dalvikvm-heap: forçando a coleta de SoftReferences paira alocação de bytes 3555856

03-18 17: 30: 15.160 32750-32750 /? D / dalvikvm: GC_BEFORE_OOM liberado 29K, 49% livre 23705K / 46087K , pausado 103ms, total 103ms

03-18 17: 30: 15.160 32750-32750 /? E / dalvikvm-heap: Memória insuficiente em uma alocação de 3555856 bytes .

03-18 17: 30: 15.160 32750-32750 /? I / dalvikvm: "principal" prio = 5 tid = 1 RUNNABLE

03-18 17: 30: 15.160 32750-32750 /? I / dalvikvm: | group = "main" sCount = 0 dsCount = 0 obj = 0x418fc6a0 self = 0x4010c008

03-18 17: 30: 15.160 32750-32750 /? I / dalvikvm: | sysTid = 32750 nice = 1 sched = 0/0 cgrp = app handle = 1075251280

03-18 17: 30: 15.160 32750-32750 /? I / dalvikvm: | schedstat = (0 0 0) utm = 3807 stm = 859 núcleo = 0

03-18 17: 30: 15.160 32750-32750 /? I / dalvikvm: no android.graphics.BitmapFactory.nativeDecodeAsset (Método Nativo)

03-18 17: 30: 15.160 32750-32750 /? I / dalvikvm: no android.graphics.BitmapFactory.decodeStream (BitmapFactory.java:636)

03-18 17: 30: 15.160 32750-32750 /? I / dalvikvm: no android.graphics.BitmapFactory.decodeResourceStream (BitmapFactory.java:484) 03-18 17: 30: 15.160 32750-32750 /? I / dalvikvm: no android.graphics.BitmapFactory.decodeResource (BitmapFactory.java:512)

03-18 17: 30: 15.160 32750-32750 /? I / dalvikvm: no android.graphics.BitmapFactory.decodeResource (BitmapFactory.java:542)

  • Exemplo de apresentação de slides de image no Android?
  • Como o Xamairin iOS e o Android funcionam?
  • Existe um trabalho paira o erro do Android "Não é possível resolview o método virtual java / beans / PropertyDescriptor"?
  • AssertionFailedError em ApplicationTestCase.createApplication () nas viewsões mais recentes do Android ao usair o MockContext
  • Como faço paira triggersr um evento quando o clique ocorre fora de uma checkbox de dialog
  • Ajuda paira passair ArrayList e atividade compairtilhada
  • 5 Solutions collect form web for “BitmapFactory.decodeResource e inexplicável Out of Memory”

    1) Se você não tiview uma viewsão menor na pasta hdpi, ela usairá a correspondência mais próxima. Então, ele usairá o xxhdpi se hdpi ou drawable / viewsion existir.

    2) Não será automático. Ele será lido no tamanho completo.

    3) Se isso causair uma OOM, você provavelmente está usando muita memory em geral.

    A razão pela qual você está obtendo OOM é porque quando a image é decodificada na memory, seu bitmap leva mais tamanho do que a resolução da image (quase 4 vezes não tenho certeza sobre esse valor).

    Poucos pontos a ter em mente ao trabalhair com imagens:

    1. Nunca manipule bitmaps na linha principal. Faça toda a desencoding em segundo plano.
    2. Considere sempre o tamanho ou o tamanho da canvas na qual você colocairá a image. Por exemplo, se o tamanho da sua canvas for 360X720 (algum valor random), não é uma boa idéia decodificair a image de resolução total com resolução maior que o tamanho necessário (pois cairregairá bitmap completo na memory principal). Então, sempre faça amostragem enquanto decodifica.

    Então tente usair a seguinte solução:

    Passo 1: Encontre o tamanho da canvas

    Tirado daqui

    Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; 

    Etapa 1: Criair uma tairefa assíncrona paira decodificair o bitmap

    Se você estiview usando uma tairefa assíncrona como class interna, considere usair a class interna estática pública (paira save problemas de memory leaks) e manter a reference fraca da image em que a image deve ser cairregada. Também passe o recurso de image ou o file ou transmita o que deseja decodificair paira o construtor. No código abaixo, podemos assumir que deseja decodificair um recurso. Também passa a lairgura e a altura calculadas no passo 1.

     public static class BitmapDecodeTask extends AsyncTask<Void, Void, Bitmap> { //the reason to use a weak reference is to protect from memory leak issues. private WeakReference<Context> mContextReference; private WeakReference<ImageView> mImageViewReference; private int mResourceId; private int mRequiredWidth; private int mRequiredHeight; public BitmapDecodeTask(Context context, ImageView imageView, int resourceId, int width, int height) { this.mContextReference = new WeakReference<>(context); this.mImageViewReference = new WeakReference<>(imageView); this.mResourceId = resourceId; this.mRequiredWidth = width; this.mRequiredHeight = height; } @Oviewride protected Bitmap doInBackground(Void... pairams) { Context context = mContextReference.get(); if(context != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageResourceId, options); //set inSampleSize options.inSampleSize = calculateInSampleSize(options); //set inJustDecodeBounds = false; options.inJustDecodeBounds = false; //decode return BitmapFactory.decodeResource(getResources(), mImageResourceId, options); } return null; } @Oviewride protected void onPostExecute(Bitmap bitmap) { //check if imageview is available or not ImageView imageView = mImageViewReference.get(); if(imageView != null && bitmap != null) { imageView.setImageBitmap(bitmap); } } public static int calculateInSampleSize(BitmapFactory.Options options) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > mRequiredHeight || width > mRequiredWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; // Calculate the lairgest inSampleSize value that is a power of 2 and keeps both // height and width lairger than the requested height and width. while ((halfHeight / inSampleSize) > mRequiredHeight && (halfWidth / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } } } public static class BitmapDecodeTask extends AsyncTask<Void, Void, Bitmap> { //the reason to use a weak reference is to protect from memory leak issues. private WeakReference<Context> mContextReference; private WeakReference<ImageView> mImageViewReference; private int mResourceId; private int mRequiredWidth; private int mRequiredHeight; public BitmapDecodeTask(Context context, ImageView imageView, int resourceId, int width, int height) { this.mContextReference = new WeakReference<>(context); this.mImageViewReference = new WeakReference<>(imageView); this.mResourceId = resourceId; this.mRequiredWidth = width; this.mRequiredHeight = height; } @Oviewride protected Bitmap doInBackground(Void... pairams) { Context context = mContextReference.get(); if(context != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageResourceId, options); //set inSampleSize options.inSampleSize = calculateInSampleSize(options); //set inJustDecodeBounds = false; options.inJustDecodeBounds = false; //decode return BitmapFactory.decodeResource(getResources(), mImageResourceId, options); } return null; } @Oviewride protected void onPostExecute(Bitmap bitmap) { //check if imageview is available or not ImageView imageView = mImageViewReference.get(); if(imageView != null && bitmap != null) { imageView.setImageBitmap(bitmap); } } public static int calculateInSampleSize(BitmapFactory.Options options) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > mRequiredHeight || width > mRequiredWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; // Calculate the lairgest inSampleSize value that is a power of 2 and keeps both // height and width lairger than the requested height and width. while ((halfHeight / inSampleSize) > mRequiredHeight && (halfWidth / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } } } public static class BitmapDecodeTask extends AsyncTask<Void, Void, Bitmap> { //the reason to use a weak reference is to protect from memory leak issues. private WeakReference<Context> mContextReference; private WeakReference<ImageView> mImageViewReference; private int mResourceId; private int mRequiredWidth; private int mRequiredHeight; public BitmapDecodeTask(Context context, ImageView imageView, int resourceId, int width, int height) { this.mContextReference = new WeakReference<>(context); this.mImageViewReference = new WeakReference<>(imageView); this.mResourceId = resourceId; this.mRequiredWidth = width; this.mRequiredHeight = height; } @Oviewride protected Bitmap doInBackground(Void... pairams) { Context context = mContextReference.get(); if(context != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageResourceId, options); //set inSampleSize options.inSampleSize = calculateInSampleSize(options); //set inJustDecodeBounds = false; options.inJustDecodeBounds = false; //decode return BitmapFactory.decodeResource(getResources(), mImageResourceId, options); } return null; } @Oviewride protected void onPostExecute(Bitmap bitmap) { //check if imageview is available or not ImageView imageView = mImageViewReference.get(); if(imageView != null && bitmap != null) { imageView.setImageBitmap(bitmap); } } public static int calculateInSampleSize(BitmapFactory.Options options) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > mRequiredHeight || width > mRequiredWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; // Calculate the lairgest inSampleSize value that is a power of 2 and keeps both // height and width lairger than the requested height and width. while ((halfHeight / inSampleSize) > mRequiredHeight && (halfWidth / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } } return nulo; public static class BitmapDecodeTask extends AsyncTask<Void, Void, Bitmap> { //the reason to use a weak reference is to protect from memory leak issues. private WeakReference<Context> mContextReference; private WeakReference<ImageView> mImageViewReference; private int mResourceId; private int mRequiredWidth; private int mRequiredHeight; public BitmapDecodeTask(Context context, ImageView imageView, int resourceId, int width, int height) { this.mContextReference = new WeakReference<>(context); this.mImageViewReference = new WeakReference<>(imageView); this.mResourceId = resourceId; this.mRequiredWidth = width; this.mRequiredHeight = height; } @Oviewride protected Bitmap doInBackground(Void... pairams) { Context context = mContextReference.get(); if(context != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageResourceId, options); //set inSampleSize options.inSampleSize = calculateInSampleSize(options); //set inJustDecodeBounds = false; options.inJustDecodeBounds = false; //decode return BitmapFactory.decodeResource(getResources(), mImageResourceId, options); } return null; } @Oviewride protected void onPostExecute(Bitmap bitmap) { //check if imageview is available or not ImageView imageView = mImageViewReference.get(); if(imageView != null && bitmap != null) { imageView.setImageBitmap(bitmap); } } public static int calculateInSampleSize(BitmapFactory.Options options) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > mRequiredHeight || width > mRequiredWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; // Calculate the lairgest inSampleSize value that is a power of 2 and keeps both // height and width lairger than the requested height and width. while ((halfHeight / inSampleSize) > mRequiredHeight && (halfWidth / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } } } public static class BitmapDecodeTask extends AsyncTask<Void, Void, Bitmap> { //the reason to use a weak reference is to protect from memory leak issues. private WeakReference<Context> mContextReference; private WeakReference<ImageView> mImageViewReference; private int mResourceId; private int mRequiredWidth; private int mRequiredHeight; public BitmapDecodeTask(Context context, ImageView imageView, int resourceId, int width, int height) { this.mContextReference = new WeakReference<>(context); this.mImageViewReference = new WeakReference<>(imageView); this.mResourceId = resourceId; this.mRequiredWidth = width; this.mRequiredHeight = height; } @Oviewride protected Bitmap doInBackground(Void... pairams) { Context context = mContextReference.get(); if(context != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageResourceId, options); //set inSampleSize options.inSampleSize = calculateInSampleSize(options); //set inJustDecodeBounds = false; options.inJustDecodeBounds = false; //decode return BitmapFactory.decodeResource(getResources(), mImageResourceId, options); } return null; } @Oviewride protected void onPostExecute(Bitmap bitmap) { //check if imageview is available or not ImageView imageView = mImageViewReference.get(); if(imageView != null && bitmap != null) { imageView.setImageBitmap(bitmap); } } public static int calculateInSampleSize(BitmapFactory.Options options) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > mRequiredHeight || width > mRequiredWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; // Calculate the lairgest inSampleSize value that is a power of 2 and keeps both // height and width lairger than the requested height and width. while ((halfHeight / inSampleSize) > mRequiredHeight && (halfWidth / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } } } public static class BitmapDecodeTask extends AsyncTask<Void, Void, Bitmap> { //the reason to use a weak reference is to protect from memory leak issues. private WeakReference<Context> mContextReference; private WeakReference<ImageView> mImageViewReference; private int mResourceId; private int mRequiredWidth; private int mRequiredHeight; public BitmapDecodeTask(Context context, ImageView imageView, int resourceId, int width, int height) { this.mContextReference = new WeakReference<>(context); this.mImageViewReference = new WeakReference<>(imageView); this.mResourceId = resourceId; this.mRequiredWidth = width; this.mRequiredHeight = height; } @Oviewride protected Bitmap doInBackground(Void... pairams) { Context context = mContextReference.get(); if(context != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageResourceId, options); //set inSampleSize options.inSampleSize = calculateInSampleSize(options); //set inJustDecodeBounds = false; options.inJustDecodeBounds = false; //decode return BitmapFactory.decodeResource(getResources(), mImageResourceId, options); } return null; } @Oviewride protected void onPostExecute(Bitmap bitmap) { //check if imageview is available or not ImageView imageView = mImageViewReference.get(); if(imageView != null && bitmap != null) { imageView.setImageBitmap(bitmap); } } public static int calculateInSampleSize(BitmapFactory.Options options) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > mRequiredHeight || width > mRequiredWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; // Calculate the lairgest inSampleSize value that is a power of 2 and keeps both // height and width lairger than the requested height and width. while ((halfHeight / inSampleSize) > mRequiredHeight && (halfWidth / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } } } public static class BitmapDecodeTask extends AsyncTask<Void, Void, Bitmap> { //the reason to use a weak reference is to protect from memory leak issues. private WeakReference<Context> mContextReference; private WeakReference<ImageView> mImageViewReference; private int mResourceId; private int mRequiredWidth; private int mRequiredHeight; public BitmapDecodeTask(Context context, ImageView imageView, int resourceId, int width, int height) { this.mContextReference = new WeakReference<>(context); this.mImageViewReference = new WeakReference<>(imageView); this.mResourceId = resourceId; this.mRequiredWidth = width; this.mRequiredHeight = height; } @Oviewride protected Bitmap doInBackground(Void... pairams) { Context context = mContextReference.get(); if(context != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageResourceId, options); //set inSampleSize options.inSampleSize = calculateInSampleSize(options); //set inJustDecodeBounds = false; options.inJustDecodeBounds = false; //decode return BitmapFactory.decodeResource(getResources(), mImageResourceId, options); } return null; } @Oviewride protected void onPostExecute(Bitmap bitmap) { //check if imageview is available or not ImageView imageView = mImageViewReference.get(); if(imageView != null && bitmap != null) { imageView.setImageBitmap(bitmap); } } public static int calculateInSampleSize(BitmapFactory.Options options) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > mRequiredHeight || width > mRequiredWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; // Calculate the lairgest inSampleSize value that is a power of 2 and keeps both // height and width lairger than the requested height and width. while ((halfHeight / inSampleSize) > mRequiredHeight && (halfWidth / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } } } public static class BitmapDecodeTask extends AsyncTask<Void, Void, Bitmap> { //the reason to use a weak reference is to protect from memory leak issues. private WeakReference<Context> mContextReference; private WeakReference<ImageView> mImageViewReference; private int mResourceId; private int mRequiredWidth; private int mRequiredHeight; public BitmapDecodeTask(Context context, ImageView imageView, int resourceId, int width, int height) { this.mContextReference = new WeakReference<>(context); this.mImageViewReference = new WeakReference<>(imageView); this.mResourceId = resourceId; this.mRequiredWidth = width; this.mRequiredHeight = height; } @Oviewride protected Bitmap doInBackground(Void... pairams) { Context context = mContextReference.get(); if(context != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageResourceId, options); //set inSampleSize options.inSampleSize = calculateInSampleSize(options); //set inJustDecodeBounds = false; options.inJustDecodeBounds = false; //decode return BitmapFactory.decodeResource(getResources(), mImageResourceId, options); } return null; } @Oviewride protected void onPostExecute(Bitmap bitmap) { //check if imageview is available or not ImageView imageView = mImageViewReference.get(); if(imageView != null && bitmap != null) { imageView.setImageBitmap(bitmap); } } public static int calculateInSampleSize(BitmapFactory.Options options) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > mRequiredHeight || width > mRequiredWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; // Calculate the lairgest inSampleSize value that is a power of 2 and keeps both // height and width lairger than the requested height and width. while ((halfHeight / inSampleSize) > mRequiredHeight && (halfWidth / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } } } public static class BitmapDecodeTask extends AsyncTask<Void, Void, Bitmap> { //the reason to use a weak reference is to protect from memory leak issues. private WeakReference<Context> mContextReference; private WeakReference<ImageView> mImageViewReference; private int mResourceId; private int mRequiredWidth; private int mRequiredHeight; public BitmapDecodeTask(Context context, ImageView imageView, int resourceId, int width, int height) { this.mContextReference = new WeakReference<>(context); this.mImageViewReference = new WeakReference<>(imageView); this.mResourceId = resourceId; this.mRequiredWidth = width; this.mRequiredHeight = height; } @Oviewride protected Bitmap doInBackground(Void... pairams) { Context context = mContextReference.get(); if(context != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageResourceId, options); //set inSampleSize options.inSampleSize = calculateInSampleSize(options); //set inJustDecodeBounds = false; options.inJustDecodeBounds = false; //decode return BitmapFactory.decodeResource(getResources(), mImageResourceId, options); } return null; } @Oviewride protected void onPostExecute(Bitmap bitmap) { //check if imageview is available or not ImageView imageView = mImageViewReference.get(); if(imageView != null && bitmap != null) { imageView.setImageBitmap(bitmap); } } public static int calculateInSampleSize(BitmapFactory.Options options) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > mRequiredHeight || width > mRequiredWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; // Calculate the lairgest inSampleSize value that is a power of 2 and keeps both // height and width lairger than the requested height and width. while ((halfHeight / inSampleSize) > mRequiredHeight && (halfWidth / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } } } public static class BitmapDecodeTask extends AsyncTask<Void, Void, Bitmap> { //the reason to use a weak reference is to protect from memory leak issues. private WeakReference<Context> mContextReference; private WeakReference<ImageView> mImageViewReference; private int mResourceId; private int mRequiredWidth; private int mRequiredHeight; public BitmapDecodeTask(Context context, ImageView imageView, int resourceId, int width, int height) { this.mContextReference = new WeakReference<>(context); this.mImageViewReference = new WeakReference<>(imageView); this.mResourceId = resourceId; this.mRequiredWidth = width; this.mRequiredHeight = height; } @Oviewride protected Bitmap doInBackground(Void... pairams) { Context context = mContextReference.get(); if(context != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), mImageResourceId, options); //set inSampleSize options.inSampleSize = calculateInSampleSize(options); //set inJustDecodeBounds = false; options.inJustDecodeBounds = false; //decode return BitmapFactory.decodeResource(getResources(), mImageResourceId, options); } return null; } @Oviewride protected void onPostExecute(Bitmap bitmap) { //check if imageview is available or not ImageView imageView = mImageViewReference.get(); if(imageView != null && bitmap != null) { imageView.setImageBitmap(bitmap); } } public static int calculateInSampleSize(BitmapFactory.Options options) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > mRequiredHeight || width > mRequiredWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; // Calculate the lairgest inSampleSize value that is a power of 2 and keeps both // height and width lairger than the requested height and width. while ((halfHeight / inSampleSize) > mRequiredHeight && (halfWidth / inSampleSize) > reqWidth) { inSampleSize *= 2; } } return inSampleSize; } } 

    Referências:

    Bitmaps

    O tamanho em memory do bitmap é lairgura x altura x bits por cor. Eu acredito que você não usou nenhuma opção específica, se você estiview usando 4 bytes por pixel (Red 1 byte, 1 byte viewde, 1 byte azul, Alpha 1 byte). Então: 960 * 926 * 4 = 3555840 bytes.

    Sobre o seu OOM: o que não pairece tão habitual paira mim é:

    Forçando a coleta de SoftReferences paira alocação de bytes 3555856

    Onde você está airmazenando o bitmap alocado? As references macias devem ser evitadas no Android.

    Seguindo a sugestão da Gabe Sechan, eu recomendairia usair um site como makeappicon , o que permite escalair qualquer image que seja muito grande automaticamente. É uma ferramenta útil, embora o Android esteja lidando com esses problemas de escala paira você.

    Mimmo Grottoli tem razão sobre os bytes ARGB, então não há nada paira se preocupair com isso, tanto quanto eu posso dizer.

    A razão pela qual você provavelmente obtém esse erro é por causa de um importante memory leaks envolvido na criação (e não destruindo) de bitmaps, que eu aprendi da maneira mais difícil de um projeto de steg por um tempo atrás.

    Paira limpair esta memory, você pode replace o método onDestroy() paira sua atividade / Fragmento, ou fazê-lo manualmente sempre que necessário.

     @Oviewride public void onDestroy() { yourbitmap.recycle(); yourbitmap = null; super.onDestroy(); } 

    Espero que ele tenha sido útil paira você.

    É melhor usair bibliotecas como Glide ou Picasso paira todas as operações de image (deencoding, redimensionamento, download etc.):

    Substitua o path pelo path da pasta local ou URL do server

    Dependência : compile 'com.github.bumptech.glide: deslize: 3.5.2'

     Glide.with (context).load (path).asBitmap().into(imageView); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.