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

  • Home
  • SEARCH
  • 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 7514375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:28:39+00:00 2026-05-30T00:28:39+00:00

I’m getting a lot of these exceptions from users: java.lang.OutOfMemoryError: bitmap size exceeds VM

  • 0

I’m getting a lot of these exceptions from users: java.lang.OutOfMemoryError: bitmap size exceeds VM budget – but i’m unable to reproduce the problem on the emulator.

I’m using this as my ImageDownloader http://code.google.com/p/android-imagedownloader/source/browse/trunk/src/com/example/android/imagedownloader/ImageDownloader.java#185 and the problem occurs on line 185 when trying to decode the image.

There is a lot of other questions here on stackoverflow, regarding this error, but none that fits my specific case. The solution in this question could work: https://stackoverflow.com/a/823966 but i can’t seem to get it to work.

Here is what i changed in my ImageDownloader:

final HttpEntity entity = response.getEntity();
if (entity != null) {
    InputStream inputStream = null;
    try {
        inputStream = entity.getContent();
        // return BitmapFactory.decodeStream(inputStream);
        // Bug on slow connections, fixed in future release.

        FlushedInputStream flushedStream = new FlushedInputStream(inputStream);

        // Decode image size
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(flushedStream, null, o);
        Log.d(LOG_TAG, "decodeStream - outWidth=" + o.outWidth + " outHeight=" + o.outHeight);

        // 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 scale = 1;
        while (o.outWidth / scale / 2 >= REQUIRED_SIZE && o.outHeight / scale / 2 >= REQUIRED_SIZE)
            scale *= 2;

        // Decode with inSampleSize
        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize = scale;
        return BitmapFactory.decodeStream(flushedStream, null, o2);
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
        entity.consumeContent();
    }
}

It fails when calling decodeStream() the second time. Error is SkImageDecoder::Factory returned null. I figured maybe the inputStream is closed or not available on the second call, so i then tried to use BufferedHttpEntity in the first line above, but with no luck.

Can someone guide me towards the right direction? Thanks.

  • 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-30T00:28:40+00:00Added an answer on May 30, 2026 at 12:28 am

    Download the image first and put into a byte array. decodeStream returns null after a certain period of time when using input stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string

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.