开发者

out of memory error in android app [duplicate]

开发者 https://www.devze.com 2023-03-28 09:41 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: OutOfMemoryError: bitmap size exceeds VM budget :- Android
This question already has answers here: Closed 11 years ago.

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/AndroidR开发者_开发百科untime(14107):     at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2353)

how to avoid this error, please help me friends


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

Image Size Issue


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

0

精彩评论

暂无评论...
验证码 换一张
取 消