android : bitmap size exceeds VM budget
<p>I am using android Camera. Also using auto focusing feature. After capturing image more then 10 times getting the following exception:<br>
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget</p>

<p>my source code is following: </p>

<pre><code>    PictureCallback jpegCallback = new PictureCallback() {
            public void onPictureTaken(byte[] data, Camera camera) {

                try {
                    // Bitmap bmp = BitmapFactory.decodeStream(new
                    // ByteArrayInputStream(data));
                    Utility.gc();
                    Bitmap bmp = decodeFile(data);
                    Utility.gc();
                    // BitmapFactory.decodeByteArray(data, 0,
                    // data.length, o);
                    // Bitmap bmpCompressed = rotateBitmap(bmp, 90, 320, 430);

                    Bitmap bmpCompressed = Bitmap.createScaledBitmap(bmp, 430, 320,
                            true);
                    bmp.recycle();
                    Utility.gc();
                    writeBmp(bmpCompressed);
                    bmpCompressed.recycle();
                    Utility.gc();

                } catch (Exception e) {
                    Log.e(Constants.TAG, e.getMessage(), e);

                } finally {
                    isImageCapture = true;
                }

            }

        };
private Bitmap decodeFile(byte[] buffer) {

        // Decode image size
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(new ByteArrayInputStream(buffer), null, o);

        // The new size we want to scale to
        final int REQUIRED_SIZE = 70;

        // 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; REQUIRED_SIZE || height_tmp / 2 &lt; REQUIRED_SIZE)
                break;
            width_tmp /= 2;
            height_tmp /= 2;
            scale *= 2;
        }

        // Decode with inSampleSize
        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize = scale;
        return BitmapFactory.decodeStream(new ByteArrayInputStream(buffer),
                null, o2);

    }
</code></pre>

<p>how can i get rid from the above mention exception?</p>
