Thanks a lot, Romain! Question though - even if the gallery is not
converting the views, why doesn't it release references to them as you
move away?

Say, I move from view 0 to view 1, with view 0 being completely off-
screen, the gallery should remove its reference to view 0 since it is
no longer needed, and thus allow the gc to free up any memory it
holds. In fact, when I go back to view 0, I can see that a new view is
created. So what happened to the old view 0? Even with view conversion
not working, there shouldn't be memory leaks.

-Mike


On Dec 3, 11:04 pm, Romain Guy <[EMAIL PROTECTED]> wrote:
> I just checked and the bug is simply that Gallery does not convert the
> views. I'll try to fix it as soon as possible.
>
>
>
> On Wed, Dec 3, 2008 at 10:45 PM, EboMike <[EMAIL PROTECTED]> wrote:
>
> > I've already asked this in <a href="http://groups.google.com/group/
> > android-developers/msg/9cdbf47be2505810?hl=en">This thread</a>: Here
> > is a pretty simple Gallery setup. It seems to leak with every image
> > that's loaded (see the original thread for details).
>
> > I'm tempted to file it as a bug, but I want to mention it here first
> > to make sure I'm not just making a simple mistake in my usage of the
> > Gallery. Also (as mentioned in another thread), convertView is always
> > null -- the Gallery never seems to recycle any views. Why?
>
> > To make this run, you will need to put a JPG file into the data folder
> > (see code).
>
> > package ebomike.memorytest;
>
> > import android.app.Activity;
> > import android.content.Context;
> > import android.graphics.Bitmap;
> > import android.graphics.BitmapFactory;
> > import android.graphics.drawable.BitmapDrawable;
> > import android.os.Bundle;
> > import android.util.Log;
> > import android.view.View;
> > import android.view.ViewGroup;
> > import android.widget.BaseAdapter;
> > import android.widget.Gallery;
> > import android.widget.ImageView;
>
> > public class MemoryTest extends Activity {
>
> >        Gallery g;
>
> >    /** Called when the activity is first created. */
> >   [EMAIL PROTECTED]
> >    public void onCreate(Bundle savedInstanceState) {
>
> >                String filePath;
>
> >                // NOTE: Make this point to a JPEG file.
> >                filePath = getFilesDir().getPath();
> >                filePath += "/TEST_IMAGE.jpg";
>
> >        super.onCreate(savedInstanceState);
> >        setContentView(R.layout.main);
>
> >        g = (Gallery) findViewById(R.id.Gallery01);
> >        g.setAdapter(new FullImageAdapter(this, filePath));
> >    }
>
> >    class FullImageAdapter extends BaseAdapter
> >    {
> >        Context context;
> >        String path;
>
> >        FullImageAdapter(Context c, String path)
> >        {
> >                context = c;
> >                this.path = path;
> >        }
>
> >        public int getCount()
> >        {
> >                return 1024;
> >        }
>
> >        public int getViewTypeCount()
> >        {
> >                return 1;
> >        }
>
> >        public boolean hasStableIds()
> >        {
> >                return true;
> >        }
>
> >        public int getItemViewType(int position)
> >        {
> >                return 0;
> >        }
>
> >        public View getView(int position, View convertView, ViewGroup
> > parent)
> >        {
> >                ImageView view;
>
> >                if (convertView != null)
> >                {
> >                        // Note that we never get here. Why?
> >                        view = (ImageView) convertView;
> >                }
> >                else
> >                {
> >                        view = new ImageView(context);
> >                }
>
> >                Bitmap bitmap = BitmapFactory.decodeFile(path);
> >                BitmapDrawable drawable = new BitmapDrawable(bitmap);
> >                view.setImageDrawable(drawable);
>
> >                return view;
> >        }
>
> >        public Object getItem(int position)
> >        {
> >                return position;
> >        }
>
> >        public long getItemId(int position)
> >        {
> >                return position;
> >        }
> >    }
> > }
>
> > The layout:
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > android"
> >    android:orientation="vertical"
> >    android:layout_width="fill_parent"
> > android:layout_height="fill_parent">
> > <TextView
> >    android:layout_width="fill_parent"
> >    android:layout_height="wrap_content"
> >    android:text="@string/hello"
> >    />
> > <Gallery android:id="@+id/Gallery01"
> > android:layout_width="fill_parent"
> > android:layout_height="fill_parent"></Gallery>
>
> > </LinearLayout>
>
> --
> Romain Guywww.curious-creature.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to