1

I am trying to retrieve a list of images and text from a web service. I have first coded to get the images to a list using Simple Adapter. The images are getting displayed the app is showing an error and in the Logcat the following errors occur...

04-26 10:55:39.483: ERROR/dalvikvm-heap(1047): 8850-byte external allocation too large for this process.
04-26 10:55:39.493: ERROR/(1047): VM won't let us allocate 8850 bytes
04-26 10:55:39.563: ERROR/AndroidRuntime(1047): Uncaught handler: thread Thread-96 exiting due to uncaught exception
04-26 10:55:39.573: ERROR/AndroidRuntime(1047): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-26 10:55:39.573: ERROR/AndroidRuntime(1047): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-26 10:55:39.573: ERROR/AndroidRuntime(1047): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:451)
04-26 10:55:39.573: ERROR/AndroidRuntime(1047): at com.stellent.gorinka.AsyncImageLoaderv.loadImageFromUrl(AsyncImageLoaderv.java:57)
04-26 10:55:39.573: ERROR/AndroidRuntime(1047): at com.stellent.gorinka.AsyncImageLoaderv2ドル.run(AsyncImageLoaderv.java:41)
04-26 10:55:40.393: ERROR/dalvikvm-heap(1047): 14600-byte external allocation too large for this process.
04-26 10:55:40.403: ERROR/(1047): VM won't let us allocate 14600 bytes
04-26 10:55:40.493: ERROR/AndroidRuntime(1047): Uncaught handler: thread Thread-93 exiting due to uncaught exception
04-26 10:55:40.493: ERROR/AndroidRuntime(1047): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-26 10:55:40.493: ERROR/AndroidRuntime(1047): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-26 10:55:40.493: ERROR/AndroidRuntime(1047): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:451)
04-26 10:55:40.493: ERROR/AndroidRuntime(1047): at com.stellent.gorinka.AsyncImageLoaderv.loadImageFromUrl(AsyncImageLoaderv.java:57)
04-26 10:55:40.493: ERROR/AndroidRuntime(1047): at com.stellent.gorinka.AsyncImageLoaderv2ドル.run(AsyncImageLoaderv.java:41)
04-26 10:55:40.594: INFO/Process(584): Sending signal. PID: 1047 SIG: 3

Here's the coding in the adapter...

final ImageView imageView = (ImageView) rowView.findViewById(R.id.image);
 AsyncImageLoaderv asyncImageLoader=new AsyncImageLoaderv();
 Bitmap cachedImage = asyncImageLoader.loadDrawable(imgPath, new AsyncImageLoaderv.ImageCallback() {
 public void imageLoaded(Bitmap imageDrawable, String imageUrl) {
 imageView.setImageBitmap(imageDrawable);
 }
 });
 imageView.setImageBitmap(cachedImage);

To load the image...

public static Bitmap loadImageFromUrl(String url) {
 InputStream inputStream;Bitmap b;
 try {
 inputStream = (InputStream) new URL(url).getContent();
 BitmapFactory.Options bpo= new BitmapFactory.Options();
 bpo.inSampleSize=2;
 b=BitmapFactory.decodeStream(inputStream, null,bpo );
 return b;
 } catch (IOException e) {
 throw new RuntimeException(e);
 }
 //return null;
 } 

Please tell me how to fix the error....

asked Apr 26, 2010 at 5:37
1

1 Answer 1

1

You are getting OOM Errors because your Bitmap is taking up too much of memory. See if this can help: Handling large Bitmaps. Down sampling the image to half its original size may still result in an image that is just too big for the runtime.

answered Apr 26, 2010 at 8:03
Sign up to request clarification or add additional context in comments.

1 Comment

I have tried these methods. The app is running smoothly sometimes but crashing many times displaying the error about the memory ...

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.