Re: [android-developers] List adapter: failing to recycle views = lots of memory allocated?

2010-03-02 Thread Mark Murphy
Romain Guy wrote:
> That's sad :(

:: shrug ::

It's going to take a metric buttload of work for me to navigate the
whole process, in particular figuring out everything the site
instructions don't tell me. If I'm going to do that work, I'm going to
do it seriously, which means not just to fix an old SDK sample. I need
to get more bang for my proverbial buck, so to speak.

Besides, writing an Android book isn't as big a hurdle for me as it
might be for most people. :-)

That being said, if there's anyone reading this thread that is
contributing to Android through the public process, who wouldn't mind me
kibitzing a bit, drop me a line.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

-- 
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


Re: [android-developers] List adapter: failing to recycle views = lots of memory allocated?

2010-03-02 Thread Romain Guy
That's sad :(

On Tue, Mar 2, 2010 at 10:49 AM, Mark Murphy  wrote:
> Romain Guy wrote:
>> Even better, submit a patch :)
>
> Only if I decide to write a book on how to work with the firmware and
> contribute to the AOSP.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android Development Wiki: http://wiki.andmob.org
>
> --
> 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
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

-- 
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


Re: [android-developers] List adapter: failing to recycle views = lots of memory allocated?

2010-03-02 Thread Mark Murphy
Romain Guy wrote:
> Even better, submit a patch :)

Only if I decide to write a book on how to work with the firmware and
contribute to the AOSP.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

-- 
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


Re: [android-developers] List adapter: failing to recycle views = lots of memory allocated?

2010-03-02 Thread Romain Guy
Even better, submit a patch :)

On Tue, Mar 2, 2010 at 10:43 AM, Mark Murphy  wrote:
> Romain Guy wrote:
>> *Always* reuse convertView.
>
> Should we file a bug report, then, for the List8.java SDK sample? That
> *was* the context of this discussion.
>
> http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List8.html
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android Training in NYC: 1-2 May 2010: http://guruloft.com
>
> --
> 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
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

-- 
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


Re: [android-developers] List adapter: failing to recycle views = lots of memory allocated?

2010-03-02 Thread Mark Murphy
Romain Guy wrote:
> *Always* reuse convertView.

Should we file a bug report, then, for the List8.java SDK sample? That
*was* the context of this discussion.

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List8.html

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in NYC: 1-2 May 2010: http://guruloft.com

-- 
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


Re: [android-developers] List adapter: failing to recycle views = lots of memory allocated?

2010-03-02 Thread Romain Guy
*Always* reuse convertView.

On Tue, Mar 2, 2010 at 7:09 AM, Mark Murphy  wrote:
> Mark Wyszomierski wrote:
>> I thought though that in earlier versions of the SDK that
>> listview would internally release views more quickly if you weren't
>> using convertView, and were allocating all of them like in the above
>> example?
>
> I don't think that was the case. I think the example is just sub-optimal.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Warescription: Three Android Books, Plus Updates, One Low Price!
>
> --
> 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
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

-- 
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


Re: [android-developers] List adapter: failing to recycle views = lots of memory allocated?

2010-03-02 Thread Mark Murphy
Mark Wyszomierski wrote:
> I thought though that in earlier versions of the SDK that
> listview would internally release views more quickly if you weren't
> using convertView, and were allocating all of them like in the above
> example?

I don't think that was the case. I think the example is just sub-optimal.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
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


[android-developers] List adapter: failing to recycle views = lots of memory allocated?

2010-03-02 Thread Mark Wyszomierski
Hi,

I'm looking at List8 in the sdk api samples folder. In this example,
the list adapter doesn't recycle 'convertView':

  public View getView(int position, View convertView, ViewGroup
parent) {
// Make an ImageView to show a photo
ImageView i = new ImageView(mContext);

i.setImageResource(mPhotos.get(position));
i.setAdjustViewBounds(true);
i.setLayoutParams(new AbsListView.LayoutParams(
  LayoutParams.WRAP_CONTENT,
  LayoutParams.WRAP_CONTENT));
// Give it a nice background
i.setBackgroundResource(R.drawable.picture_frame);
return i;
  }

I'm running this example on a nexus one. I am flinging the listview up
and down, and it seems to grow the heap up to 8mb at times before
releasing anything. This doesn't happen when convertView is recycled,
the memory usage remains quite stable as expected.

I started working on a project where there's an adapter implemented
which also does not recycle convertView. Same behavior as above, I can
grow the heap to 12/13mb before anything is released. So I end up
seeing a lot of out of memory exceptions as I play with other parts of
the app and so much memory is already allocated.

There's no reason not to use convertView, and none of this behavior is
unexpected. I thought though that in earlier versions of the SDK that
listview would internally release views more quickly if you weren't
using convertView, and were allocating all of them like in the above
example? By earlier versions, I mean like the first version of the SDK
two years ago, when we were trying to figure out what convertView was
at all. Just curious,

Thanks

-- 
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