Monday, March 4, 2013

[android-developers] cost of view instantiation versus memory bloat

I have a widget that potentially uses many Views.  In looking at the source for other view-intensive widgets (like ListView), I understand that it's a fairly computationally expensive process to instantiate Views.  I see they're recycling children - creating them on demand, then caching them, and re-using them with updated properties when one is required.

My concern is that in my case (with so many potential Views) that the cost of keeping references to them in memory might be worse than the cost of instantiating them.  I'm tracking the total number of Views in the cache and see it reach as much as 60-70 at times.

The requirement is such that I can't reduce the number of Views used.

When the number is as high as I've mentioned, is caching and recycling Views still a "better" prospect than new instantiation on-demand?  I believe that if I did not cache, the unused Views would be garbage-collected properly (there shouldn't be any references that I'm not catching).

TYIA.

--
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment