3

Possible Duplicate:
OutOfMemoryError: bitmap size exceeds VM budget :- Android

in my app i have an custom list view which displays an image and some text views for each list.

I have the images in .png format in my drawable. Every time i am listing out the image after converting it into a drawable. If the user opens the list view activity and goes back to the previous activity and once again opens the list view continuously i got an out of memory error.

To avoid this i have set the bitmap = null and i have even recycled it. But still the same error exists.

if(icon_bmp != null)
        {
        icon_bmp.recycle();
        icon_bmp = null;
        System.gc();
        }

but still i am getting the same out of memory error. Following is my error log

 Uncaught handler: thread main exiting due to uncaught exception
08-12 19:23:16.168: ERROR/AndroidRuntime(14107): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.graphics.Bitmap.nativeCreate(Native Method)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:346)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:372)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at com.pack.LocalDish.CustomAdapter.DishListViewAdapter.populateListData(DishListViewAdapter.java:129)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at com.pack.LocalDish.CustomAdapter.DishListViewAdapter.getView(DishListViewAdapter.java:82)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.widget.AbsListView.obtainView(AbsListView.java:1256)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.widget.ListView.makeAndAddView(ListView.java:1668)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.widget.ListView.fillDown(ListView.java:637)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.widget.ListView.fillGap(ListView.java:608)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2531)
08-12 19:23:16.168: ERROR/AndroidRuntime(14107):     at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2353)

how to avoid this error, please help me friends

Community
  • 1
  • 1
Siva K
  • 4,968
  • 14
  • 82
  • 161

2 Answers2

0

You can just finish the Listview activity by calling finish() method and clear all the objects ,drawables to null in the onDestroy Method.

Kakey
  • 3,936
  • 5
  • 29
  • 45
0

Here is the way in which you can deal with your problem.

Image Size Issue

Community
  • 1
  • 1
Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242