Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6188413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:13:38+00:00 2026-05-24T02:13:38+00:00

Possible Duplicate: OutOfMemoryError: bitmap size exceeds VM budget :- Android Im in the process

  • 0

Possible Duplicate:
OutOfMemoryError: bitmap size exceeds VM budget :- Android

Im in the process of writing a program which uses images from the gallery and then displays them in an activity (one image pr. activity). However I’ve been bumping into this error over and over again for three days straight without doing any progress of eliminating it:

07-25 11:43:36.197: ERROR/AndroidRuntime(346): java.lang.OutOfMemoryError: bitmap size exceeds VM budget

My code flow is as follows:

When the user presses a button an intent is fired leading to the gallery:

 Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
 galleryIntent.setType("image/*");
 startActivityForResult(galleryIntent, 0);

Once the user has selected an image the image is presented in an imageview:

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical">

<ImageView
    android:background="#ffffffff"
    android:id="@+id/image"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:maxWidth="250dip"
    android:maxHeight="250dip"
    android:adjustViewBounds="true"/>

 </LinearLayout>

In the onActivityResult method i have:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if(resultCode == RESULT_OK) {
        switch(requestCode) {
        case 0:             // Gallery
            String realPath = getRealPathFromURI(data.getData());
            File imgFile = new File(realPath);
            Bitmap myBitmap;
            try {
                myBitmap = decodeFile(imgFile);
                Bitmap rotatedBitmap = resolveOrientation(myBitmap);
                img.setImageBitmap(rotatedBitmap);
                OPTIONS_TYPE = 1;
            } catch (IOException e) { e.printStackTrace(); }

            insertImageInDB(realPath);

            break;
        case 1:             // Camera

The decodeFile method is from here and the resolveOrientation method just wraps the bitmap into a matrix and turns it 90 degrees clockwise.

I really hope someone can help me resolve this matter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:13:38+00:00Added an answer on May 24, 2026 at 2:13 am

    it is because your bitmap size is large, so reduce the image size manually, or by programmatically

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = 8;
    Bitmap preview_bitmap = BitmapFactory.decodeFile(mPathName, options);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: OutOfMemoryError: bitmap size exceeds VM budget :- Android In my application I
Possible Duplicate: OutOfMemoryError: bitmap size exceeds VM budget :- Android I have code like
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
Possible Duplicate: How to detect if JavaScript is disabled? I have a website which
Possible Duplicate: Difference between Convert.tostring() and .tostring() Hi Carrying on from this question What
Possible Duplicate: Lock the Android device programmatically I want to lock the screen through
Possible Duplicate: Updating progress dialog in Activity from AsyncTask I am developing my first
Possible Duplicate: Find out the instance id from within an ec2 machine I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.