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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:36:23+00:00 2026-05-27T15:36:23+00:00

I am working on an application where i have images being downloaded asynchronously for

  • 0

I am working on an application where i have images being downloaded asynchronously for SlideShows. One SlideShow contains 10 slides, hence 10 images are downloaded when slideshow is opened. After i scroll through 10-15 slideshows approximately i start getting memory warning and following Exception in the trace and app crashes.

Here is the trace:

12-23 12:23:53.124: ERROR/dalvikvm-heap(3067): 45850-byte external allocation too large for this process.
12-23 12:23:53.134: ERROR/dalvikvm(3067): Out of memory: Heap Size=13127KB, Allocated=11913KB, Bitmap Size=11407KB
12-23 12:23:53.134: ERROR/GraphicsJNI(3067): VM won't let us allocate 45850 bytes
12-23 12:23:53.134: DEBUG/skia(3067): --- decoder->decode returned false
12-23 12:23:53.134: WARN/dalvikvm(3067): threadid=46: thread exiting with uncaught exception (group=0x400259f8)
12-23 12:23:53.134: ERROR/AndroidRuntime(3067): FATAL EXCEPTION: Thread-1016
12-23 12:23:53.134: ERROR/AndroidRuntime(3067): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
12-23 12:23:53.134: ERROR/AndroidRuntime(3067):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
12-23 12:23:53.134: ERROR/AndroidRuntime(3067):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:468)
12-23 12:23:53.134: ERROR/AndroidRuntime(3067):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:332)
12-23 12:23:53.134: ERROR/AndroidRuntime(3067):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
12-23 12:23:53.134: ERROR/AndroidRuntime(3067):     at android.graphics.drawable.Drawable.createFromStream(Drawable.java:657)
12-23 12:23:53.134: ERROR/AndroidRuntime(3067):     at com.nbcu.myApp.appsupport.AsyncImageLoader.loadImageFromUrl(AsyncImageLoader.java:98)
12-23 12:23:53.134: ERROR/AndroidRuntime(3067):     at com.nbcu.myApp.appsupport.AsyncImageLoader$2.run(AsyncImageLoader.java:70)
12-23 12:23:53.154: WARN/ActivityManager(96):   Force finishing activity com.nbcu.myApp.activities/com.nbcu.myApp.controllers.StoriesListController
12-23 12:23:53.224: ERROR/dalvikvm-heap(3067): 45850-byte external allocation too large for this process.
12-23 12:23:53.234: DEBUG/SurfaceFlinger(96): Layer::setBuffers(this=0x2fabc0), pid=96, w=1, h=1
12-23 12:23:53.234: ERROR/dalvikvm(3067): Out of memory: Heap Size=13127KB, Allocated=11948KB, Bitmap Size=11407KB
12-23 12:23:53.234: ERROR/GraphicsJNI(3067): VM won't let us allocate 45850 bytes
12-23 12:23:53.234: ERROR/Error(3067): Message = java.lang.OutOfMemoryError: bitmap size exceeds VM budget

The code where images are being downloaded is:

public void run() {

        Looper.prepare();
        for (int i = 0; i < slides.size(); i++) {
            try {

                final SlideShowItem story = slides.get(i);
                if (story.getImage() == null) {
                    Drawable cachedImage = Utils.database.getRSSImage(Constants.StoriesTable, story.getItemId());

                    if (cachedImage != null) {
                        story.setImage(cachedImage);

                    } else {
                        cachedImage = asyncImageLoader.loadDrawable(story.getImagePath(), new ImageCallback() {
                            public void imageLoaded(Drawable imageDrawable, String imageUrl) {


                                story.setImage(imageDrawable);
                                Utils.database.storeRSSItemImage(Constants.StoriesTable, imageDrawable, story.getItemId());
                            }
                        });
                    }
                }

                Thread.sleep(500);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        Looper.loop();
    }

Code for loadDrawable() is:

public Drawable loadDrawable(final String imageUrl, final ImageCallback imageCallback) {

    final Handler handler = new Handler() {

        public void handleMessage(Message message) {

            imageCallback.imageLoaded((Drawable) message.obj, imageUrl);
        }
    };
    new Thread() {

        public void run() {

                Drawable drawable = loadImageFromUrl(imageUrl);
                // System.out.println("image url: " + imageUrl);
                if (drawable != null)
                {
                    Message message = handler.obtainMessage(0, drawable);
                    handler.sendMessage(message);
                }
        }

    }.start();
    return null;
}

and the code for loadImageFromURL() is:

  public static Drawable loadImageFromUrl(String url) {

    Drawable image = null;

    try {
        InputStream in = (java.io.InputStream) new java.net.URL(url).getContent();
        if (in != null) {
            image = Drawable.createFromStream(in, "image");
        }
        in.close();

    } catch (Exception ex) {
        // ex.printStackTrace();
        Log.v("Exception ", "Asyn Image.In LoadImageFromURL Message: " + ex.toString());

    }
    return image;
}

Once images are downloaded they are cached. I am unable to find a workaround to avoid this exception. what could be the reason? I have also tried setting image views null when activity is destroyed but it has done nothing for me? Any help is appreciated. Thanks in advance.

  • 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-27T15:36:24+00:00Added an answer on May 27, 2026 at 3:36 pm

    Android is a Mobile OS. It has a limited memory, so, you cannot cache all the slides.size(). I assume the size > 15. For example, im running a FastCV algorithm with a HD image as markers, 250000 x 180000 pixels and if i run the program on pc, work fine, if i do it on the mobile phone dont, because the memory is not enough.

    I think you can solve the problem, if only caché 10 – 15 images, depends the size of them. If scroll, then cache new one in the memory already used.

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

Sidebar

Related Questions

I am working on an application where I have an images folder relative to
I am working with small application for display bubbles images on android screen.I have
I'm working on an image processing application where I have two threads on top
I am working on an application an have an issue about running shell command
I am working on splitting out an existing, working application that I currently have
I have an application I have been working on and it can be slow
I'm working on an application where users have to make a call and type
I'm working on an application that will have attachments, and I would like to
I'm working on an application so i have write an dll which contain a
I have pretty much finished my first working Symbian application, but in my hastened

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.