title: Out of Memory Error while loading bitmaps
body: <p>i have an android app with 3 acitivtys:</p>
  
  <p>A1 --<em>starts</em>--> A2 --<em>starts</em>--> A3 --<em>when finished his process: starts</em>--> A1</p>
  
  <p>(so i don't "finish();" an app. i start the next activitys with "startActivity(..);" the whole time after userinteraction)</p>
  
  <p>so there is a loop in these 3 activitys.
  On each Activity, i display 3-9 pictures, located on the SD-card, which i load with my following function:</p>
  
  <pre><code>try
  {
      Uri selectedImageURI = Uri.parse(strImagePath);
      File imgFile = new  File(getRealPathFromURI(selectedImageURI, c));
      Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
      ivTmp.setImageBitmap(myBitmap);
  }catch (Exception e)
  {
      return null;
  }
  </code></pre>
  
  <p>This all works.
  But sometimes (after looping a few times through my activitys), my app crashes..</p>
  
  <p>Logcat tells me:</p>
  
  <pre><code>01-16 13:42:15.863: DEBUG/dalvikvm(23161): GC_BEFORE_OOM freed 10K, 9% free 59019K/64400K, paused 29ms, total 30ms
  01-16 13:42:15.863: ERROR/dalvikvm-heap(23161): Out of memory on a 8018704-byte allocation.
  01-16 13:42:15.863: ERROR/AndroidRuntime(23161): FATAL EXCEPTION: main
          java.lang.OutOfMemoryError
          at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
          at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
          at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
          at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
          at android.content.res.Resources.loadDrawable(Resources.java:1965)
          at android.content.res.Resources.getDrawable(Resources.java:660)
          at android.widget.ImageView.resolveUri(ImageView.java:616)
          at android.widget.ImageView.setImageResource(ImageView.java:349)
          at &lt;MyApp&gt;.MyActivity$6.run(MyActivity.java:143)
          at android.os.Handler.handleCallback(Handler.java:725)
          at android.os.Handler.dispatchMessage(Handler.java:92)
          at android.os.Looper.loop(Looper.java:137)
          at android.app.ActivityThread.main(ActivityThread.java:5039)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:511)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Someone can give my some tips how to handle the crashes?
  Maybe its because my activitys are set to state "paused" instead of closing them correctly?</p>