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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:24:08+00:00 2026-05-24T20:24:08+00:00

I am trying to download an image using a web service. The actual image

  • 0

I am trying to download an image using a web service. The actual image stream is delivered as a part of the response string. I am running this request in a background process using AsyncTask. After the thread starts to receive the actual byte stream the Memory heap is getting increased. I am putting the log below.

08-22 12:26:45.131: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 2322 objects / 190832 bytes in 39ms
08-22 12:26:47.231: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 1352 objects / 409784 bytes in 29ms
08-22 12:26:47.381: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 625 objects / 219384 bytes in 31ms
08-22 12:26:47.621: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 1036 objects / 336544 bytes in 29ms
08-22 12:26:47.621: INFO/dalvikvm-heap(31088): Grow heap (frag case) to 3.413MB for 334198-byte allocation
08-22 12:26:47.671: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 0 objects / 0 bytes in 42ms
08-22 12:26:47.941: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 1651 objects / 506808 bytes in 31ms
08-22 12:26:47.951: INFO/dalvikvm-heap(31088): Grow heap (frag case) to 3.672MB for 501292-byte allocation
08-22 12:26:47.991: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 0 objects / 0 bytes in 39ms
08-22 12:26:49.701: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 2255 objects / 749472 bytes in 28ms
08-22 12:26:49.701: INFO/dalvikvm-heap(31088): Grow heap (frag case) to 4.071MB for 751934-byte allocation
08-22 12:26:49.741: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 0 objects / 0 bytes in 37ms
08-22 12:26:51.561: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 2731 objects / 1027912 bytes in 28ms
08-22 12:26:51.711: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 587 objects / 103544 bytes in 31ms
08-22 12:26:51.711: INFO/dalvikvm-heap(31088): Grow heap (frag case) to 4.669MB for 1127896-byte allocation
08-22 12:26:51.761: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 0 objects / 0 bytes in 43ms
08-22 12:26:52.801: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 3872 objects / 1486920 bytes in 31ms
08-22 12:26:53.011: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 963 objects / 196184 bytes in 30ms
08-22 12:26:53.011: INFO/dalvikvm-heap(31088): Grow heap (frag case) to 5.565MB for 1691840-byte allocation
08-22 12:26:53.051: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 0 objects / 0 bytes in 40ms
08-22 12:26:54.291: VERBOSE/AlarmManager(103): Alarm triggering: Alarm{4669d808 type 0 com.facebook.katana}
08-22 12:26:54.561: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 5670 objects / 2174152 bytes in 28ms
08-22 12:26:54.656: ERROR/ApiMethod.onHttpOperationComplete(586): FacebookApiException: 102/The session has been invalidated because the user has changed the password.
08-22 12:26:54.691: INFO/LSState(103): EventReceiver:android.intent.action.NOTIFICATION_UPDATE
08-22 12:26:54.711: VERBOSE/AlarmManager(103): Adding Alarm{46661060 type 0 com.facebook.katana} Aug 22 12:27:54 pm
08-22 12:26:55.151: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 1963 objects / 365552 bytes in 45ms
08-22 12:26:55.161: INFO/dalvikvm-heap(31088): Grow heap (frag case) to 6.909MB for 2537756-byte allocation
08-22 12:26:55.201: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 0 objects / 0 bytes in 39ms
08-22 12:26:56.961: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 8165 objects / 3209680 bytes in 35ms
08-22 12:26:57.601: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 3189 objects / 596336 bytes in 40ms
08-22 12:26:57.611: INFO/dalvikvm-heap(31088): Grow heap (frag case) to 8.927MB for 3806630-byte allocation
08-22 12:26:57.651: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 0 objects / 0 bytes in 38ms
08-22 12:26:58.461: VERBOSE/AlarmManager(103): Alarm triggering: Alarm{46935248 type 0 com.facebook.katana}
08-22 12:26:58.851: ERROR/ApiMethod.onHttpOperationComplete(586): FacebookApiException: 102/The session has been invalidated because the user has changed the password.
08-22 12:26:58.911: INFO/LSState(103): EventReceiver:android.intent.action.NOTIFICATION_UPDATE
08-22 12:26:58.931: VERBOSE/AlarmManager(103): Adding Alarm{469006d0 type 0 com.facebook.katana} Aug 22 12:27:28 pm
08-22 12:27:00.041: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 11558 objects / 4635672 bytes in 72ms
08-22 12:27:01.021: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 5947 objects / 1072128 bytes in 30ms
08-22 12:27:01.041: INFO/dalvikvm-heap(31088): Grow heap (frag case) to 11.951MB for 5709940-byte allocation
08-22 12:27:01.111: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 0 objects / 0 bytes in 64ms
08-22 12:27:06.171: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 10917 objects / 5903536 bytes in 30ms
08-22 12:27:08.861: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 10522 objects / 1912024 bytes in 30ms
08-22 12:27:08.881: INFO/dalvikvm-heap(31088): Grow heap (frag case) to 13.472MB for 5401196-byte allocation
08-22 12:27:08.941: DEBUG/dalvikvm(31088): GC_FOR_MALLOC freed 0 objects / 0 bytes in 61ms

On the fifth line u can see the heap size is 3.413 MB and on second
last line it grows up to 13.472MB.

This is the code I am using to fetch data inside asyncTask class.

@Override
        protected String doInBackground(String... params) {
            // TODO Auto-generated method stub
            RestClient client = new RestClient(CALL_URL);
            client.AddParam("token", params[0]);

            client.AddParam("filename", params[3]); 
            try {
                client.Execute(RestClient.RequestMethod.GET);
            } catch (Exception e) {
                e.printStackTrace();
            }

            String response = client.getResponse();
            return response;    
        }

These are the methods inside the RestClient class which actually deals with the httprequest

private void executeRequest(HttpUriRequest request, String url)
    {
        HttpClient client = new DefaultHttpClient();

        HttpResponse httpResponse;

        try {
            httpResponse = client.execute(request);
            responseCode = httpResponse.getStatusLine().getStatusCode();
            message = httpResponse.getStatusLine().getReasonPhrase();

            HttpEntity entity = httpResponse.getEntity();

            if (entity != null) {

                InputStream instream = entity.getContent();
                response = convertStreamToString(instream);

                // Closing the input stream will trigger connection release
                instream.close();
            }

        } catch (ClientProtocolException e)  {
            client.getConnectionManager().shutdown();
            e.printStackTrace();
        } catch (IOException e) {
            client.getConnectionManager().shutdown();
            e.printStackTrace();
        }
    }

    private static String convertStreamToString(InputStream is) {

        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();

        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return sb.toString();
    }

What could be the possible reason. How can I effectively do this with out taking this much memory in android?

  • 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-24T20:24:09+00:00Added an answer on May 24, 2026 at 8:24 pm

    I’m not familiar with Android, but you may store content on the filesystem instead of memory.

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

Sidebar

Related Questions

I am trying to download this image using C# http://www.pinkice.com/data/product_image/1/13954Untitled-1.jpg When I try to
I'm trying to download an image using this code: from urllib import urlretrieve urlretrieve('http://gdimitriou.eu/wp-content/uploads/2008/04/google-image-search.jpg',
I'm trying to download images (.jpg) from web folder using wget. I want to
I am trying to download the image from the url http://a3.twimg.com/profile_images/414797877/05052008321_bigger.jpg I am using
Using PHP I'm trying to download/save the following image: http://www.bobshop.nl/catalog/product_image.php?size=detail&id=42428 When you load this
I'm trying to download several images in response to a single http request. On
I am trying to download image from Amazon using pre-signed URL. Here is the
I'm trying to download a PNG image from a Flash application using a Java
i am trying to download a image file using ftp, on every code i
I am trying to download an image from an url...My code is : 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.