title: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
body: <p>So I've got a lazy image loader for my <code>ListView</code>. I also use <a href="https://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue/823966#823966">this tutorial</a> for better memory management and have <code>SoftReference</code> Bitmap images stored in my <code>ArrayList</code>.</p>
  
  <p>My <code>ListView</code> works loads 8 images from a DB then once the user scrolls all the way to the bottom it loads another 8 etc etc. There was no issue when there were around 35 images or less, but any more and my app Force Closes with <code>OutOfMemoryError</code>.</p>
  
  <p>The thing that I can't understand is I have my code inside a try catch:</p>
  
  <pre><code>try
  {
      BitmapFactory.Options o = new BitmapFactory.Options();
      o.inJustDecodeBounds = true;
      BitmapFactory.decodeByteArray(image, 0, image.length, o);
  
      //Find the correct scale value. It should be the power of 2.
      int width_tmp = o.outWidth, height_tmp = o.outHeight;
      int scale = 1;
  
      while(true)
      {
          if(width_tmp/2 &lt; imageWidth || height_tmp/2 &lt; imageHeight)
          {
              break;
          }
  
          width_tmp/=2;
          height_tmp/=2;
          scale++;
      }
  
      //Decode with inSampleSize
      BitmapFactory.Options o2 = new BitmapFactory.Options();
      o2.inSampleSize = scale;
      bitmapImage = BitmapFactory.decodeByteArray(image, 0, image.length, o2);        
  }
  catch (Exception e)
  {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>But the try catch block isn't catching the <code>OutOfMemory</code> exception and from what I understand the <code>SoftReference</code> Bitmap images should be cleared when the application is running out of memory stopping the <code>OutOfMemory</code> exception being thrown.</p>
  
  <p>What am I doing wrong here?</p>