title: BitmapFactory.decodeByteArray OutOfMemory
body: <p>i'm trying to get a Jpeg from <code>Camera.PictureCallback onPictureTaken</code> but when i do this</p>
  
  <p><code>bitmapImage = BitmapFactory.decodeByteArray(data, 0, data.length);</code></p>
  
  <p>The first time this is what appears on logcat:</p>
  
  <p>Grow heap (frag case) to 48.886MB for 15728656-byte allocation</p>
  
  <p>And when I try to retake a picture the app crashes with this stack trace:</p>
  
  <pre><code>java.lang.OutOfMemoryError
              at android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method)
              at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:603)
              at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:626)
              at com.delsorboilario.brianzashop.Scatta$5.onPictureTaken(Scatta.java:216)
              at android.hardware.Camera$EventHandler.handleMessage(Camera.java:987)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:146)
              at android.app.ActivityThread.main(ActivityThread.java:5511)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>this is the code:</p>
  
  <pre><code>android.hardware.Camera.PictureCallback jpegCallback = new android.hardware.Camera.PictureCallback() {
      @Override
      public void onPictureTaken(byte[] data, android.hardware.Camera camera) {
  
           bitmapImage = BitmapFactory.decodeByteArray(data, 0, data.length);
  
  
          Uri tempUri = getImageUri(getApplicationContext(), bitmapImage);
  
          File finalFile = new File(getRealPathFromURI(tempUri));
  
          System.out.println("aaaaaa "+finalFile);
  
  
      }
  };
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Following MicheleLacorte's suggest, i'm try to recycle Bitmap after take <code>File finalFile</code></p>
  
  <p>and its ok but when I try to display image from that path i've the same error.</p>