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 7866973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:34:54+00:00 2026-06-03T00:34:54+00:00

My Android application connects to a service to request a file from our server.

  • 0

My Android application connects to a service to request a file from our server. At request time, the file type is unknown but the server replies will a Hashmap that contains the file extension and a byte array of the file data.

My mobile app then takes this data, and if it is a jpg, png, txt, or html file it will display the file on the screen. If it is a different file type, a file is created and the system is prompted to attempt to open the file in an external application.

The text, html, and external files are all working with no problem. Images are working fine for the first image I load, but if I make a second call to the server to load the next image in the list I often get this error:

   E/AndroidRuntime(390): java.lang.OutOfMemoryError: bitmap size exceeds VM budget

I’m using the same server call, and storing the new information over the old information.
Here is my code of where I am actually loading the image data:

  imageView.setImageBitmap(BitmapFactory.decodeByteArray(bytes, 0, bytes.length));

Is there a way to handle the memory issue so my application doesn’t crash? I have already tried scaling down the images from the server side to make them much smaller and more manageable (but this seems like a bandaid instead of a proper fix.) Currently I am just using the raw bytes and the BitmapFactory to load the imageView, but if there is another way, I could always create a temp file with the actual png or jpg if that would help in any way.

Can someone offer some advice on the best way to handle this?

  • 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-06-03T00:34:57+00:00Added an answer on June 3, 2026 at 12:34 am

    Images use a lot of the few megabytes RAM your app has. 1Megapixel = 4Megabyte raw imagedata (RGBA_8888 mode at least) that the app needs to hold in memory. Multiple large images will crash on any device.

    • download images to filesystem, use them from there and decode them with a sample size > 1 if they are bigger than you need them / you have memory.
    • immediately recyle() images if you don’t need them. Their native buffer does not play well with GC.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android application that connects to Facebook to request authorization of an
Is there any way to connect to a SQL Server from an Android application
We are developing a mobile application(iPhone, Android, WM) which mainly connects with the server
I'm learning Android and I'm stuck with my service. My application connects via Socket
I am having an android application that connects with the pc. It workd on
I wrote a chat application for Android using SocketChannel. It connects successfully with the
I am creating an Android application that connects to the Fogbugz XML API (sends
I am working on an android application for my company which connects to a
I'm building a web-service for an Android application that needs to connect to a
I'm developing an Android chat application. On startup the application launches a service. The

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.