Skip to content Skip to sidebar Skip to footer

Getting An Exception Outofmemoryerror

I have someone getting an error while loading a bunch of images on my app and I'm not sure whats causing it. This is the error he gets. LINE 135 is at the bottom. I'm thinking he i

Solution 1:

You need to scale down the bitmaps and load a scaled down version in memory.

http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

Use appropriateBitmapFactory.decode method as needed.

Here's an Example:

Out of Memory error with Bitmap

Note: As of Android 3.0 (API Level 11), the pixel data is stored on the Dalvik heap along with the associated bitmap.

On Android 2.3.3 (API level 10) and lower, using recycle() is recommended. If you're displaying large amounts of bitmap data in your app, you're likely to run into OutOfMemoryError errors. The recycle() method allows an app to reclaim memory as soon as possible.

Android 3.0 (API Level 11) introduces theBitmapFactory.Options.inBitmap field. If this option is set, decode methods that take the Options object will attempt to reuse an existing bitmap when loading content. This means that the bitmap's memory is reused, resulting in improved performance, and removing both memory allocation and de-allocation.

http://developer.android.com/training/displaying-bitmaps/manage-memory.html

Solution 2:

in your first AsyncTask class num++; always increasing, so at some value it goes beyond memory space allocated for this program, you should put a control for that

Post a Comment for "Getting An Exception Outofmemoryerror"