Are you recycling your bitmaps?  I'm not sure what your
getThumbnailBitmap is doing, but I have something that sounds similar
where I rescale my bitmaps like so:

        public static Bitmap getBitmap(Context context,String photoUriPath)
throws Exception {
                Uri photoUri = Uri.parse(photoUriPath);
                InputStream photoStream = context.getContentResolver
().openInputStream(photoUri);
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inSampleSize=2;
                Bitmap photoBitmap = BitmapFactory.decodeStream
(photoStream,null,options);
                int h = photoBitmap.getHeight();
                int w = photoBitmap.getWidth();
                if((w>h)&&(w>128)){
                        double ratio = 128d/w;
                        w=128;
                        h=(int)(ratio*h);
                }
                else if((h>w)&&(h>128)){
                        double ratio = 128d/h;
                        h=128;
                        w=(int)(ratio*w);
                }
                Bitmap scaled = Bitmap.createScaledBitmap(photoBitmap, w, h, 
true);
                photoBitmap.recycle();
                return scaled;
        }

I make sure I call recycle() on the original bitmap to conserve
memory.

On Mar 31, 6:41 pm, Alexey <avolo...@gmail.com> wrote:
> Hi All , I definitely have a memory leak problem and i'm trying to
> figure out there. After 6-10 config changes i'm getting out of memory
> in regards to  BitmapFactory.  I'm kind of suspect that this is going
> on within adapter.
>  I have a listview . ListItems are an thumbnail image ( ImageView )
> and TextView for text.
>
> Here is the getView code.
>
>                                 if (convertView != null )
>                                         newView = convertView;
>                                 else {
>                                         LayoutInflater layout = 
> LayoutInflater.from(mContext);
>                                         newView = 
> layout.inflate(R.layout.list_item, null);
>                                 }
>
>                                 TextView tView = (TextView) 
> newView.findViewById(R.id.title);
>
>                                 tView.setText(nItem.Title);
>
>                                 ImageView iView = (ImageView) 
> newView.findViewById(R.id.image);
>
>                                 Bitmap thumbnail = nItem.getThumbnailBitmap();
>                                 if (thumbnail != null) {
>                                         iView.setImageBitmap(thumbnail);
>
> and get ThumbnailBitmap() is basically
> BitmapFactory.decodeByteArray ..  Is it possible that i'm leaking
> drawables ? Heap is not increasing by the way .
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to